Refactor openApi parameters

This commit is contained in:
2019-08-29 14:11:08 +02:00
parent 679dd2e4c5
commit 20e9c3f7ef

View File

@@ -65,7 +65,6 @@ paths:
404: 404:
description: Citizen not found description: Citizen not found
/citizens: /citizens:
description: Get all citizens
get: get:
security: security:
- JWTAuth: [] - JWTAuth: []
@@ -74,7 +73,26 @@ paths:
- citizen - citizen
operationId: getCitizens operationId: getCitizens
parameters: parameters:
- name: page - $ref: '#/components/parameters/page'
- $ref: '#/components/parameters/limit'
- $ref: '#/components/parameters/sort'
- $ref: '#/components/parameters/direction'
- $ref: '#/components/parameters/search'
responses:
200:
description: The Citizen objects
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/CitizenResponse'
components:
parameters:
page:
name: page
in: query in: query
description: The current page description: The current page
example: 1 example: 1
@@ -83,9 +101,10 @@ paths:
default: 1 default: 1
type: integer type: integer
minimum: 1 minimum: 1
- name: limit limit:
name: limit
in: query in: query
description: The number of citizen per page description: The number of object per page
example: 50 example: 50
required: false required: false
schema: schema:
@@ -93,14 +112,16 @@ paths:
type: integer type: integer
minimum: 1 minimum: 1
maximum: 50 maximum: 50
- name: sort sort:
name: sort
in: query in: query
description: The sort field name description: The sort field name
example: first_name example: first_name
required: false required: false
schema: schema:
type: string type: string
- name: direction direction:
name: direction
in: query in: query
description: The sort direction description: The sort direction
example: asc example: asc
@@ -109,25 +130,15 @@ paths:
type: string type: string
default: asc default: asc
enum: [asc, desc] enum: [asc, desc]
- name: search search:
name: search
in: query in: query
description: A text to seach description: A text to seach
example: John Doe example: John Doe
required: false required: false
schema: schema:
type: string type: string
responses:
200:
description: The Citizen object
content:
application/json:
schema:
$ref: '#/components/schemas/CitizenResponse'
404:
description: Citizen not found
components:
securitySchemes: securitySchemes:
JWTAuth: JWTAuth:
type: http type: http
@@ -143,6 +154,14 @@ components:
example: example:
e74be8e4-6823-47c4-bd1b-789725b2fa8e e74be8e4-6823-47c4-bd1b-789725b2fa8e
UuidEntity:
properties:
id:
type: object
properties:
id:
$ref: '#/components/schemas/UUID'
UserBase: UserBase:
properties: properties:
username: username:
@@ -153,10 +172,7 @@ components:
UserResponse: UserResponse:
allOf: allOf:
- $ref: '#/components/schemas/UserBase' - $ref: '#/components/schemas/UserBase'
- type: object - $ref: '#/components/schemas/UuidEntity'
properties:
id:
$ref: '#/components/schemas/UUID'
UserRequest: UserRequest:
allOf: allOf:
- $ref: '#/components/schemas/UserBase' - $ref: '#/components/schemas/UserBase'