openapi.yaml
docs/03-api/openapi.yaml
Contoh isi file untuk sistem antrian. Sesuaikan dengan implementasi proyek Anda.
openapi: 3.0.3
info:
title: BIT Antrian API — Contoh
version: 0.1.0
description: Kontrak ilustratif, bukan API yang tersedia di portal. Sesuaikan sebelum implementasi.
servers:
- url: http://localhost:8080
description: Backend contoh lokal; harus disediakan terpisah
security:
- bearerAuth: []
paths:
/api/v1/auth/login:
post:
operationId: login
security: []
summary: Login
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- email
- password
properties:
email:
type: string
format: email
password:
type: string
format: password
responses:
'200':
description: Login berhasil
content:
application/json:
schema:
$ref: '#/components/schemas/LoginResponse'
'401':
description: Credential tidak valid
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'422':
description: Input tidak valid
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/api/v1/antrian:
post:
operationId: createAntrian
summary: Mendaftarkan antrian
description: >-
Key dan payload sama mengembalikan hasil awal (201). Key sama dengan payload berbeda
menghasilkan 409.
parameters:
- name: Idempotency-Key
in: header
required: true
schema:
type: string
minLength: 1
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- service_code
properties:
service_code:
type: string
minLength: 1
example: GENERAL
responses:
'201':
description: Antrian dibuat atau hasil awal diulang
content:
application/json:
schema:
$ref: '#/components/schemas/AntrianResponse'
'401':
description: Token tidak valid
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'409':
description: QUEUE_FULL atau IDEMPOTENCY_CONFLICT
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'422':
description: VALIDATION_ERROR
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'500':
description: INTERNAL_ERROR
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/api/v1/antrian/{antrian_id}:
get:
operationId: detailAntrian
summary: Melihat antrian milik pengguna
parameters:
- name: antrian_id
in: path
required: true
schema:
type: string
format: uuid
responses:
'200':
description: Detail antrian
content:
application/json:
schema:
$ref: '#/components/schemas/AntrianResponse'
'401':
description: Token tidak valid
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'403':
description: Bukan pemilik antrian
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: ANTRIAN_NOT_FOUND
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
schemas:
Meta:
type: object
required:
- request_id
properties:
request_id:
type: string
example: req-example
AntrianResponse:
type: object
required:
- success
- message
- data
- meta
properties:
success:
type: boolean
enum:
- true
message:
type: string
example: Antrian berhasil dibuat
data:
type: object
required:
- antrian_id
- status
properties:
antrian_id:
type: string
format: uuid
example: e2f89884-b788-44c8-875f-e41f0b8cadb5
status:
type: string
example: waiting
meta:
$ref: '#/components/schemas/Meta'
LoginResponse:
type: object
required:
- success
- message
- data
properties:
success:
type: boolean
enum:
- true
message:
type: string
example: Login berhasil
data:
type: object
required:
- access_token
properties:
access_token:
type: string
ErrorResponse:
type: object
required:
- success
- message
- error
- meta
properties:
success:
type: boolean
enum:
- false
message:
type: string
error:
type: object
required:
- code
properties:
code:
type: string
example: QUEUE_FULL
meta:
$ref: '#/components/schemas/Meta'