perbaikan Swagger

This commit is contained in:
2025-08-18 09:13:11 +07:00
parent 6192a64f0a
commit aee7020096
4 changed files with 1747 additions and 989 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,55 +1,6 @@
basePath: /api/v1
definitions:
models.ErrorResponse:
properties:
code:
type: integer
error:
type: string
message:
type: string
type: object
models.ExampleGetResponse:
properties:
message:
type: string
type: object
models.ExamplePostRequest:
properties:
age:
type: integer
name:
type: string
required:
- age
- name
type: object
models.ExamplePostResponse:
properties:
id:
type: string
message:
type: string
type: object
models.HealthResponse:
properties:
details:
additionalProperties:
type: string
type: object
status:
type: string
timestamp:
type: string
type: object
models.HelloWorldResponse:
properties:
message:
type: string
version:
type: string
type: object
models.LoginRequest:
api-service_internal_models_auth.LoginRequest:
properties:
password:
type: string
@@ -59,57 +10,7 @@ definitions:
- password
- username
type: object
models.ProductCreateRequest:
properties:
name:
type: string
required:
- name
type: object
models.ProductCreateResponse:
properties:
data: {}
id:
type: string
message:
type: string
type: object
models.ProductDeleteResponse:
properties:
id:
type: string
message:
type: string
type: object
models.ProductGetByIDResponse:
properties:
id:
type: string
message:
type: string
type: object
models.ProductGetResponse:
properties:
data: {}
message:
type: string
type: object
models.ProductUpdateRequest:
properties:
name:
type: string
required:
- name
type: object
models.ProductUpdateResponse:
properties:
data: {}
id:
type: string
message:
type: string
type: object
models.TokenResponse:
api-service_internal_models_auth.TokenResponse:
properties:
access_token:
type: string
@@ -118,7 +19,7 @@ definitions:
token_type:
type: string
type: object
models.User:
api-service_internal_models_auth.User:
properties:
email:
type: string
@@ -129,6 +30,284 @@ definitions:
username:
type: string
type: object
api-service_internal_models_retribusi.AggregateData:
properties:
by_dinas:
additionalProperties:
type: integer
type: object
by_jenis:
additionalProperties:
type: integer
type: object
by_status:
additionalProperties:
type: integer
type: object
created_today:
type: integer
last_updated:
type: string
total_active:
type: integer
total_draft:
type: integer
total_inactive:
type: integer
updated_today:
type: integer
type: object
api-service_internal_models_retribusi.ErrorResponse:
properties:
code:
type: integer
error:
type: string
message:
type: string
timestamp:
type: string
type: object
api-service_internal_models_retribusi.MetaResponse:
properties:
current_page:
type: integer
has_next:
type: boolean
has_prev:
type: boolean
limit:
type: integer
offset:
type: integer
total:
type: integer
total_pages:
type: integer
type: object
api-service_internal_models_retribusi.NullableInt32:
properties:
int32:
type: integer
valid:
type: boolean
type: object
api-service_internal_models_retribusi.Retribusi:
properties:
date_created:
$ref: '#/definitions/sql.NullTime'
date_updated:
$ref: '#/definitions/sql.NullTime'
dinas:
$ref: '#/definitions/sql.NullString'
id:
type: string
jenis:
$ref: '#/definitions/sql.NullString'
kelompok_obyek:
$ref: '#/definitions/sql.NullString'
kode_tarif:
$ref: '#/definitions/sql.NullString'
pelayanan:
$ref: '#/definitions/sql.NullString'
rekening_denda:
$ref: '#/definitions/sql.NullString'
rekening_pokok:
$ref: '#/definitions/sql.NullString'
satuan:
$ref: '#/definitions/sql.NullString'
satuan_overtime:
$ref: '#/definitions/sql.NullString'
sort:
$ref: '#/definitions/api-service_internal_models_retribusi.NullableInt32'
status:
type: string
tarif:
$ref: '#/definitions/sql.NullString'
tarif_overtime:
$ref: '#/definitions/sql.NullString'
uraian_1:
$ref: '#/definitions/sql.NullString'
uraian_2:
$ref: '#/definitions/sql.NullString'
uraian_3:
$ref: '#/definitions/sql.NullString'
user_created:
$ref: '#/definitions/sql.NullString'
user_updated:
$ref: '#/definitions/sql.NullString'
type: object
api-service_internal_models_retribusi.RetribusiCreateRequest:
properties:
dinas:
maxLength: 255
minLength: 1
type: string
jenis:
maxLength: 255
minLength: 1
type: string
kelompok_obyek:
maxLength: 255
minLength: 1
type: string
kode_tarif:
maxLength: 255
minLength: 1
type: string
pelayanan:
maxLength: 255
minLength: 1
type: string
rekening_denda:
maxLength: 255
minLength: 1
type: string
rekening_pokok:
maxLength: 255
minLength: 1
type: string
satuan:
maxLength: 255
minLength: 1
type: string
satuan_overtime:
maxLength: 255
minLength: 1
type: string
status:
enum:
- draft
- active
- inactive
type: string
tarif:
type: string
tarif_overtime:
type: string
uraian_1:
type: string
uraian_2:
type: string
uraian_3:
type: string
required:
- status
type: object
api-service_internal_models_retribusi.RetribusiCreateResponse:
properties:
data:
$ref: '#/definitions/api-service_internal_models_retribusi.Retribusi'
message:
type: string
type: object
api-service_internal_models_retribusi.RetribusiDeleteResponse:
properties:
id:
type: string
message:
type: string
type: object
api-service_internal_models_retribusi.RetribusiGetByIDResponse:
properties:
data:
$ref: '#/definitions/api-service_internal_models_retribusi.Retribusi'
message:
type: string
type: object
api-service_internal_models_retribusi.RetribusiGetResponse:
properties:
data:
items:
$ref: '#/definitions/api-service_internal_models_retribusi.Retribusi'
type: array
message:
type: string
meta:
$ref: '#/definitions/api-service_internal_models_retribusi.MetaResponse'
summary:
$ref: '#/definitions/api-service_internal_models_retribusi.AggregateData'
type: object
api-service_internal_models_retribusi.RetribusiUpdateRequest:
properties:
dinas:
maxLength: 255
minLength: 1
type: string
jenis:
maxLength: 255
minLength: 1
type: string
kelompok_obyek:
maxLength: 255
minLength: 1
type: string
kode_tarif:
maxLength: 255
minLength: 1
type: string
pelayanan:
maxLength: 255
minLength: 1
type: string
rekening_denda:
maxLength: 255
minLength: 1
type: string
rekening_pokok:
maxLength: 255
minLength: 1
type: string
satuan:
maxLength: 255
minLength: 1
type: string
satuan_overtime:
maxLength: 255
minLength: 1
type: string
status:
enum:
- draft
- active
- inactive
type: string
tarif:
type: string
tarif_overtime:
type: string
uraian_1:
type: string
uraian_2:
type: string
uraian_3:
type: string
required:
- status
type: object
api-service_internal_models_retribusi.RetribusiUpdateResponse:
properties:
data:
$ref: '#/definitions/api-service_internal_models_retribusi.Retribusi'
message:
type: string
type: object
sql.NullString:
properties:
string:
type: string
valid:
description: Valid is true if String is not NULL
type: boolean
type: object
sql.NullTime:
properties:
time:
type: string
valid:
description: Valid is true if Time is not NULL
type: boolean
type: object
host: localhost:8080
info:
contact:
@@ -143,21 +322,6 @@ info:
title: API Service
version: 1.0.0
paths:
/:
get:
consumes:
- application/json
description: Returns a hello world message
produces:
- application/json
responses:
"200":
description: Hello world message
schema:
$ref: '#/definitions/models.HelloWorldResponse'
summary: Hello World endpoint
tags:
- root
/api/v1/auth/login:
post:
consumes:
@@ -169,14 +333,14 @@ paths:
name: login
required: true
schema:
$ref: '#/definitions/models.LoginRequest'
$ref: '#/definitions/api-service_internal_models_auth.LoginRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.TokenResponse'
$ref: '#/definitions/api-service_internal_models_auth.TokenResponse'
"400":
description: Bad request
schema:
@@ -201,7 +365,7 @@ paths:
"200":
description: OK
schema:
$ref: '#/definitions/models.User'
$ref: '#/definitions/api-service_internal_models_auth.User'
"401":
description: Unauthorized
schema:
@@ -233,7 +397,7 @@ paths:
"200":
description: OK
schema:
$ref: '#/definitions/models.TokenResponse'
$ref: '#/definitions/api-service_internal_models_auth.TokenResponse'
"400":
description: Bad request
schema:
@@ -281,169 +445,217 @@ paths:
summary: Register new user
tags:
- Authentication
/api/v1/example:
get:
/api/v1/retribusi/{id}:
delete:
consumes:
- application/json
description: Returns a simple message for GET request
description: Soft deletes a retribusi by setting status to 'deleted'
parameters:
- description: Retribusi ID (UUID)
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: Example GET response
description: Retribusi deleted successfully
schema:
$ref: '#/definitions/models.ExampleGetResponse'
summary: Example GET service
$ref: '#/definitions/api-service_internal_models_retribusi.RetribusiDeleteResponse'
"400":
description: Invalid ID format
schema:
$ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse'
"404":
description: Retribusi not found
schema:
$ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse'
"500":
description: Internal server error
schema:
$ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse'
summary: Delete retribusi
tags:
- example
post:
- retribusi
get:
consumes:
- application/json
description: Accepts a JSON payload and returns a response with an ID
description: Returns a single retribusi by ID
parameters:
- description: Example POST request
- description: Retribusi ID (UUID)
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: Success response
schema:
$ref: '#/definitions/api-service_internal_models_retribusi.RetribusiGetByIDResponse'
"400":
description: Invalid ID format
schema:
$ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse'
"404":
description: Retribusi not found
schema:
$ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse'
"500":
description: Internal server error
schema:
$ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse'
summary: Get Retribusi by ID
tags:
- retribusi
put:
consumes:
- application/json
description: Updates an existing retribusi record
parameters:
- description: Retribusi ID (UUID)
in: path
name: id
required: true
type: string
- description: Retribusi update request
in: body
name: request
required: true
schema:
$ref: '#/definitions/models.ExamplePostRequest'
$ref: '#/definitions/api-service_internal_models_retribusi.RetribusiUpdateRequest'
produces:
- application/json
responses:
"200":
description: Example POST response
description: Retribusi updated successfully
schema:
$ref: '#/definitions/models.ExamplePostResponse'
$ref: '#/definitions/api-service_internal_models_retribusi.RetribusiUpdateResponse'
"400":
description: Bad request or validation error
schema:
$ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse'
"404":
description: Retribusi not found
schema:
$ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse'
"500":
description: Internal server error
schema:
$ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse'
summary: Update retribusi
tags:
- retribusi
/api/v1/retribusis:
get:
consumes:
- application/json
description: Returns a paginated list of retribusis with optional summary statistics
parameters:
- default: 10
description: Limit (max 100)
in: query
name: limit
type: integer
- default: 0
description: Offset
in: query
name: offset
type: integer
- default: false
description: Include aggregation summary
in: query
name: include_summary
type: boolean
- description: Filter by status
in: query
name: status
type: string
- description: Filter by jenis
in: query
name: jenis
type: string
- description: Filter by dinas
in: query
name: dinas
type: string
- description: Search in multiple fields
in: query
name: search
type: string
produces:
- application/json
responses:
"200":
description: Success response
schema:
$ref: '#/definitions/api-service_internal_models_retribusi.RetribusiGetResponse'
"400":
description: Bad request
schema:
$ref: '#/definitions/models.ErrorResponse'
summary: Example POST service
tags:
- example
/api/v1/products:
get:
consumes:
- application/json
description: Returns a list of products
produces:
- application/json
responses:
"200":
description: Product GET response
$ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse'
"500":
description: Internal server error
schema:
$ref: '#/definitions/models.ProductGetResponse'
summary: Get product
$ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse'
summary: Get retribusi with pagination and optional aggregation
tags:
- product
- retribusi
post:
consumes:
- application/json
description: Creates a new product
description: Creates a new retribusi record
parameters:
- description: Product creation request
- description: Retribusi creation request
in: body
name: request
required: true
schema:
$ref: '#/definitions/models.ProductCreateRequest'
$ref: '#/definitions/api-service_internal_models_retribusi.RetribusiCreateRequest'
produces:
- application/json
responses:
"201":
description: Product created successfully
description: Retribusi created successfully
schema:
$ref: '#/definitions/models.ProductCreateResponse'
$ref: '#/definitions/api-service_internal_models_retribusi.RetribusiCreateResponse'
"400":
description: Bad request
description: Bad request or validation error
schema:
$ref: '#/definitions/models.ErrorResponse'
summary: Create product
$ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse'
"500":
description: Internal server error
schema:
$ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse'
summary: Create retribusi
tags:
- product
/api/v1/products/{id}:
delete:
consumes:
- application/json
description: Deletes a product by ID
parameters:
- description: Product ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: Product deleted successfully
schema:
$ref: '#/definitions/models.ProductDeleteResponse'
"404":
description: Product not found
schema:
$ref: '#/definitions/models.ErrorResponse'
summary: Delete product
tags:
- product
- retribusi
/api/v1/retribusis/stats:
get:
consumes:
- application/json
description: Returns a single product by ID
description: Returns comprehensive statistics about retribusi data
parameters:
- description: Product ID
in: path
name: id
required: true
- description: Filter statistics by status
in: query
name: status
type: string
produces:
- application/json
responses:
"200":
description: Product GET by ID response
description: Statistics data
schema:
$ref: '#/definitions/models.ProductGetByIDResponse'
"404":
description: Product not found
$ref: '#/definitions/api-service_internal_models_retribusi.AggregateData'
"500":
description: Internal server error
schema:
$ref: '#/definitions/models.ErrorResponse'
summary: Get product by ID
$ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse'
summary: Get retribusi statistics
tags:
- product
put:
consumes:
- application/json
description: Updates an existing product
parameters:
- description: Product ID
in: path
name: id
required: true
type: string
- description: Product update request
in: body
name: request
required: true
schema:
$ref: '#/definitions/models.ProductUpdateRequest'
produces:
- application/json
responses:
"200":
description: Product updated successfully
schema:
$ref: '#/definitions/models.ProductUpdateResponse'
"400":
description: Bad request
schema:
$ref: '#/definitions/models.ErrorResponse'
"404":
description: Product not found
schema:
$ref: '#/definitions/models.ErrorResponse'
summary: Update product
tags:
- product
- retribusi
/api/v1/token/generate:
post:
consumes:
@@ -455,14 +667,14 @@ paths:
name: token
required: true
schema:
$ref: '#/definitions/models.LoginRequest'
$ref: '#/definitions/api-service_internal_models_auth.LoginRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.TokenResponse'
$ref: '#/definitions/api-service_internal_models_auth.TokenResponse'
"400":
description: Bad request
schema:
@@ -499,7 +711,7 @@ paths:
"200":
description: OK
schema:
$ref: '#/definitions/models.TokenResponse'
$ref: '#/definitions/api-service_internal_models_auth.TokenResponse'
"400":
description: Bad request
schema:
@@ -509,25 +721,6 @@ paths:
summary: Generate token directly
tags:
- Token
/health:
get:
consumes:
- application/json
description: Returns the health status of the API service
produces:
- application/json
responses:
"200":
description: Health status
schema:
$ref: '#/definitions/models.HealthResponse'
"500":
description: Internal server error
schema:
$ref: '#/definitions/models.ErrorResponse'
summary: Health check endpoint
tags:
- health
schemes:
- http
- https

View File

@@ -2,16 +2,42 @@ package models
import (
"database/sql"
"database/sql/driver"
"encoding/json"
"time"
)
// NullableInt32 is a custom type to replace sql.NullInt32 for swagger compatibility
type NullableInt32 struct {
Int32 int32 `json:"int32,omitempty"`
Valid bool `json:"valid"`
}
// Scan implements the sql.Scanner interface for NullableInt32
func (n *NullableInt32) Scan(value interface{}) error {
var ni sql.NullInt32
if err := ni.Scan(value); err != nil {
return err
}
n.Int32 = ni.Int32
n.Valid = ni.Valid
return nil
}
// Value implements the driver.Valuer interface for NullableInt32
func (n NullableInt32) Value() (driver.Value, error) {
if !n.Valid {
return nil, nil
}
return n.Int32, nil
}
// Retribusi represents the data structure for the retribusi table
// with proper null handling and optimized JSON marshaling
type Retribusi struct {
ID string `json:"id" db:"id"`
Status string `json:"status" db:"status"`
Sort sql.NullInt32 `json:"sort,omitempty" db:"sort"`
Sort NullableInt32 `json:"sort,omitempty" db:"sort"`
UserCreated sql.NullString `json:"user_created,omitempty" db:"user_created"`
DateCreated sql.NullTime `json:"date_created,omitempty" db:"date_created"`
UserUpdated sql.NullString `json:"user_updated,omitempty" db:"user_updated"`
@@ -60,7 +86,7 @@ func (r Retribusi) MarshalJSON() ([]byte, error) {
Alias: (*Alias)(&r),
}
// Convert sql.Null* to pointers
// Convert NullableInt32 to pointer
if r.Sort.Valid {
sort := int(r.Sort.Int32)
aux.Sort = &sort