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 basePath: /api/v1
definitions: definitions:
models.ErrorResponse: api-service_internal_models_auth.LoginRequest:
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:
properties: properties:
password: password:
type: string type: string
@@ -59,57 +10,7 @@ definitions:
- password - password
- username - username
type: object type: object
models.ProductCreateRequest: api-service_internal_models_auth.TokenResponse:
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:
properties: properties:
access_token: access_token:
type: string type: string
@@ -118,7 +19,7 @@ definitions:
token_type: token_type:
type: string type: string
type: object type: object
models.User: api-service_internal_models_auth.User:
properties: properties:
email: email:
type: string type: string
@@ -129,6 +30,284 @@ definitions:
username: username:
type: string type: string
type: object 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 host: localhost:8080
info: info:
contact: contact:
@@ -143,21 +322,6 @@ info:
title: API Service title: API Service
version: 1.0.0 version: 1.0.0
paths: 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: /api/v1/auth/login:
post: post:
consumes: consumes:
@@ -169,14 +333,14 @@ paths:
name: login name: login
required: true required: true
schema: schema:
$ref: '#/definitions/models.LoginRequest' $ref: '#/definitions/api-service_internal_models_auth.LoginRequest'
produces: produces:
- application/json - application/json
responses: responses:
"200": "200":
description: OK description: OK
schema: schema:
$ref: '#/definitions/models.TokenResponse' $ref: '#/definitions/api-service_internal_models_auth.TokenResponse'
"400": "400":
description: Bad request description: Bad request
schema: schema:
@@ -201,7 +365,7 @@ paths:
"200": "200":
description: OK description: OK
schema: schema:
$ref: '#/definitions/models.User' $ref: '#/definitions/api-service_internal_models_auth.User'
"401": "401":
description: Unauthorized description: Unauthorized
schema: schema:
@@ -233,7 +397,7 @@ paths:
"200": "200":
description: OK description: OK
schema: schema:
$ref: '#/definitions/models.TokenResponse' $ref: '#/definitions/api-service_internal_models_auth.TokenResponse'
"400": "400":
description: Bad request description: Bad request
schema: schema:
@@ -281,169 +445,217 @@ paths:
summary: Register new user summary: Register new user
tags: tags:
- Authentication - Authentication
/api/v1/example: /api/v1/retribusi/{id}:
get: delete:
consumes: consumes:
- application/json - 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: produces:
- application/json - application/json
responses: responses:
"200": "200":
description: Example GET response description: Retribusi deleted successfully
schema: schema:
$ref: '#/definitions/models.ExampleGetResponse' $ref: '#/definitions/api-service_internal_models_retribusi.RetribusiDeleteResponse'
summary: Example GET service "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: tags:
- example - retribusi
post: get:
consumes: consumes:
- application/json - application/json
description: Accepts a JSON payload and returns a response with an ID description: Returns a single retribusi by ID
parameters: 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 in: body
name: request name: request
required: true required: true
schema: schema:
$ref: '#/definitions/models.ExamplePostRequest' $ref: '#/definitions/api-service_internal_models_retribusi.RetribusiUpdateRequest'
produces: produces:
- application/json - application/json
responses: responses:
"200": "200":
description: Example POST response description: Retribusi updated successfully
schema: 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": "400":
description: Bad request description: Bad request
schema: schema:
$ref: '#/definitions/models.ErrorResponse' $ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse'
summary: Example POST service "500":
tags: description: Internal server error
- example
/api/v1/products:
get:
consumes:
- application/json
description: Returns a list of products
produces:
- application/json
responses:
"200":
description: Product GET response
schema: schema:
$ref: '#/definitions/models.ProductGetResponse' $ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse'
summary: Get product summary: Get retribusi with pagination and optional aggregation
tags: tags:
- product - retribusi
post: post:
consumes: consumes:
- application/json - application/json
description: Creates a new product description: Creates a new retribusi record
parameters: parameters:
- description: Product creation request - description: Retribusi creation request
in: body in: body
name: request name: request
required: true required: true
schema: schema:
$ref: '#/definitions/models.ProductCreateRequest' $ref: '#/definitions/api-service_internal_models_retribusi.RetribusiCreateRequest'
produces: produces:
- application/json - application/json
responses: responses:
"201": "201":
description: Product created successfully description: Retribusi created successfully
schema: schema:
$ref: '#/definitions/models.ProductCreateResponse' $ref: '#/definitions/api-service_internal_models_retribusi.RetribusiCreateResponse'
"400": "400":
description: Bad request description: Bad request or validation error
schema: schema:
$ref: '#/definitions/models.ErrorResponse' $ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse'
summary: Create product "500":
description: Internal server error
schema:
$ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse'
summary: Create retribusi
tags: tags:
- product - retribusi
/api/v1/products/{id}: /api/v1/retribusis/stats:
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
get: get:
consumes: consumes:
- application/json - application/json
description: Returns a single product by ID description: Returns comprehensive statistics about retribusi data
parameters: parameters:
- description: Product ID - description: Filter statistics by status
in: path in: query
name: id name: status
required: true
type: string type: string
produces: produces:
- application/json - application/json
responses: responses:
"200": "200":
description: Product GET by ID response description: Statistics data
schema: schema:
$ref: '#/definitions/models.ProductGetByIDResponse' $ref: '#/definitions/api-service_internal_models_retribusi.AggregateData'
"404": "500":
description: Product not found description: Internal server error
schema: schema:
$ref: '#/definitions/models.ErrorResponse' $ref: '#/definitions/api-service_internal_models_retribusi.ErrorResponse'
summary: Get product by ID summary: Get retribusi statistics
tags: tags:
- product - retribusi
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
/api/v1/token/generate: /api/v1/token/generate:
post: post:
consumes: consumes:
@@ -455,14 +667,14 @@ paths:
name: token name: token
required: true required: true
schema: schema:
$ref: '#/definitions/models.LoginRequest' $ref: '#/definitions/api-service_internal_models_auth.LoginRequest'
produces: produces:
- application/json - application/json
responses: responses:
"200": "200":
description: OK description: OK
schema: schema:
$ref: '#/definitions/models.TokenResponse' $ref: '#/definitions/api-service_internal_models_auth.TokenResponse'
"400": "400":
description: Bad request description: Bad request
schema: schema:
@@ -499,7 +711,7 @@ paths:
"200": "200":
description: OK description: OK
schema: schema:
$ref: '#/definitions/models.TokenResponse' $ref: '#/definitions/api-service_internal_models_auth.TokenResponse'
"400": "400":
description: Bad request description: Bad request
schema: schema:
@@ -509,25 +721,6 @@ paths:
summary: Generate token directly summary: Generate token directly
tags: tags:
- Token - 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: schemes:
- http - http
- https - https

View File

@@ -2,16 +2,42 @@ package models
import ( import (
"database/sql" "database/sql"
"database/sql/driver"
"encoding/json" "encoding/json"
"time" "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 // Retribusi represents the data structure for the retribusi table
// with proper null handling and optimized JSON marshaling // with proper null handling and optimized JSON marshaling
type Retribusi struct { type Retribusi struct {
ID string `json:"id" db:"id"` ID string `json:"id" db:"id"`
Status string `json:"status" db:"status"` 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"` UserCreated sql.NullString `json:"user_created,omitempty" db:"user_created"`
DateCreated sql.NullTime `json:"date_created,omitempty" db:"date_created"` DateCreated sql.NullTime `json:"date_created,omitempty" db:"date_created"`
UserUpdated sql.NullString `json:"user_updated,omitempty" db:"user_updated"` UserUpdated sql.NullString `json:"user_updated,omitempty" db:"user_updated"`
@@ -60,7 +86,7 @@ func (r Retribusi) MarshalJSON() ([]byte, error) {
Alias: (*Alias)(&r), Alias: (*Alias)(&r),
} }
// Convert sql.Null* to pointers // Convert NullableInt32 to pointer
if r.Sort.Valid { if r.Sort.Valid {
sort := int(r.Sort.Int32) sort := int(r.Sort.Int32)
aux.Sort = &sort aux.Sort = &sort