Skip to content

Commit

Permalink
refactor: 💡 allOf
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaddeusJiang committed Aug 15, 2023
1 parent 32e896e commit 1631495
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 127 deletions.
17 changes: 1 addition & 16 deletions openapi/components/responses/BadRequest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,7 @@ description: Bad Request
content:
application/json:
schema:
type: object
required:
- status_code
- timestamp
properties:
status_code:
type: integer
enum:
- 400
status_message:
type: string
enum:
- Bad Request
timestamp:
type: string
format: date-time
$ref: ./BaseResponse.yaml
example:
status_code: 400
status_message: Bad Request
Expand Down
14 changes: 14 additions & 0 deletions openapi/components/responses/BaseResponse.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
required:
- status_code
- timestamp
properties:
data:
description: Contains the actual response data object or list of objects from each request, depending on the cardinality of the response data, this is an array (card. * or +), or a single object (card. 1 or ?)
status_code:
type: number
status_message:
type: string
timestamp:
type: string
format: date-time
example: "2020-01-01T00:00:00Z"
35 changes: 15 additions & 20 deletions openapi/components/responses/ChargingPreferencesResponse.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
required:
- status_code
- timestamp
type: object
properties:
status_code:
type: integer
format: int32
status_message:
type: string
data:
type: string
enum:
- ACCEPTED
- DEPARTURE_REQUIRED
- ENERGY_NEED_REQUIRED
- NOT_POSSIBLE
- PROFILE_TYPE_NOT_SUPPORTED
timestamp:
type: string
description: Success
content:
application/json:
schema:
allOf:
- $ref: ./BaseResponse.yaml
- properties:
data:
type: string
enum:
- ACCEPTED
- DEPARTURE_REQUIRED
- ENERGY_NEED_REQUIRED
- NOT_POSSIBLE
- PROFILE_TYPE_NOT_SUPPORTED
22 changes: 5 additions & 17 deletions openapi/components/responses/CommandResponse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,8 @@ description: Success
content:
application/json:
schema:
required:
- status_code
- timestamp
type: object
properties:
data:
$ref: ../schemas/CommandResponse.yaml
status_code:
type: integer
format: int32
example: 1000
status_message:
type: string
example: Success
timestamp:
type: string
example: "2020-01-01T00:00:00Z"
allOf:
- $ref: ./BaseResponse.yaml
- properties:
data:
$ref: ../schemas/CommandResponse.yaml
18 changes: 1 addition & 17 deletions openapi/components/responses/NotFound.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,7 @@ description: Not Found
content:
application/json:
schema:
type: object
required:
- status_code
- timestamp
properties:
status_code:
type: integer
enum:
- 404
status_message:
type: string
enum:
- Not Found
timestamp:
type: string
format: date-time

$ref: BaseResponse.yaml
example:
status_code: 404
status_message: Not Found
Expand Down
23 changes: 5 additions & 18 deletions openapi/components/responses/OneTokenResponse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,8 @@ description: Tokens GET Response with one Token object.
content:
application/json:
schema:
type: object
required:
- status_code
- timestamp
properties:
data:
$ref: ../schemas/Token.yaml
status_code:
type: integer
enum:
- 1000
status_message:
type: string
enum:
- Success
timestamp:
type: string
format: date-time
allOf:
- $ref: ./BaseResponse.yaml
- properties:
data:
$ref: ../schemas/Token.yaml
22 changes: 5 additions & 17 deletions openapi/components/responses/SessionResponse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,8 @@ description: Success
content:
application/json:
schema:
required:
- status_code
- timestamp
type: object
properties:
data:
$ref: ../schemas/Session.yaml
status_code:
type: integer
format: int32
example: 1000
status_message:
type: string
example: Success
timestamp:
type: string
example: "2020-01-01T00:00:00Z"
allOf:
- $ref: ./BaseResponse.yaml
- properties:
data:
$ref: ../schemas/Session.yaml
22 changes: 5 additions & 17 deletions openapi/components/responses/SessionsResponse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,8 @@ headers:
content:
application/json:
schema:
required:
- status_code
- timestamp
type: object
properties:
data:
$ref: ../schemas/Sessions.yaml
status_code:
type: integer
format: int32
example: 1000
status_message:
type: string
example: Success
timestamp:
type: string
example: "2020-01-01T00:00:00Z"
allOf:
- $ref: ./BaseResponse.yaml
- properties:
data:
$ref: ../schemas/Sessions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ get:
responses:
"200":
$ref: ../components/responses/SessionResponse.yaml
"401":
$ref: ../components/responses/Unauthorized.yaml

put:
tags:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ put:

responses:
"200":
description: Success
content:
application/json:
schema:
$ref: ../components/responses/ChargingPreferencesResponse.yaml
$ref: ../components/responses/ChargingPreferencesResponse.yaml
"403":
description: Forbidden
$ref: ../components/responses/Problem.yaml

0 comments on commit 1631495

Please sign in to comment.