Skip to content

Commit

Permalink
Merge pull request #10 from plugoinc/feat/OCPI-61
Browse files Browse the repository at this point in the history
fix: response_format
  • Loading branch information
ThaddeusJiang authored Aug 15, 2023
2 parents 3703f0b + 1631495 commit 94fbe98
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 123 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
25 changes: 9 additions & 16 deletions openapi/components/responses/CommandResponse.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
required:
- result
- timeout
type: object
properties:
result:
type: string
enum:
- NOT_SUPPORTED
- REJECTED
- UNKNOWN_SESSION
- ACCEPTED
timeout:
type: integer
message:
$ref: ../schemas/DisplayText.yaml
description: Success
content:
application/json:
schema:
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
9 changes: 9 additions & 0 deletions openapi/components/responses/SessionResponse.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
description: Success
content:
application/json:
schema:
allOf:
- $ref: ./BaseResponse.yaml
- properties:
data:
$ref: ../schemas/Session.yaml
16 changes: 16 additions & 0 deletions openapi/components/responses/SessionsResponse.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
description: Success
headers:
Link:
$ref: ../headers/Link.yaml
X-Total-Count:
$ref: ../headers/X-Total-Count.yaml
X-Limit:
$ref: ../headers/X-Limit.yaml
content:
application/json:
schema:
allOf:
- $ref: ./BaseResponse.yaml
- properties:
data:
$ref: ../schemas/Sessions.yaml
2 changes: 1 addition & 1 deletion openapi/components/responses/Unauthorized.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
description: Unauthorized status code
description: Unauthorized
17 changes: 17 additions & 0 deletions openapi/components/schemas/CommandResponse.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
required:
- result
- timeout
type: object
properties:
result:
type: string
enum:
- NOT_SUPPORTED
- REJECTED
- UNKNOWN_SESSION
- ACCEPTED
example: ACCEPTED
timeout:
type: integer
message:
$ref: ../schemas/DisplayText.yaml
8 changes: 2 additions & 6 deletions openapi/paths/commands_start_session.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ post:
$ref: ../components/schemas/StartSession.yaml
responses:
200:
description: OK
content:
application/json:
schema:
$ref: ../components/responses/CommandResponse.yaml
$ref: ../components/responses/CommandResponse.yaml

401:
description: Unauthorized
$ref: ../components/responses/Unauthorized.yaml
6 changes: 2 additions & 4 deletions openapi/paths/commands_stop_session.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ post:
responses:
200:
description: OK
content:
application/json:
schema:
$ref: ../components/responses/CommandResponse.yaml
$ref: ../components/responses/CommandResponse.yaml

401:
description: Unauthorized
$ref: ../components/responses/Unauthorized.yaml
13 changes: 1 addition & 12 deletions openapi/paths/sessions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,7 @@ get:
- $ref: ../components/parameters/collectionLimit.yaml
responses:
"200":
description: Success
headers:
Link:
$ref: ../components/headers/Link.yaml
X-Total-Count:
$ref: ../components/headers/X-Total-Count.yaml
X-Limit:
$ref: ../components/headers/X-Limit.yaml
content:
application/json:
schema:
$ref: ../components/schemas/Sessions.yaml
$ref: ../components/responses/SessionsResponse.yaml
"401":
description: Unauthorized
$ref: ../components/responses/Unauthorized.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,9 @@ get:
- $ref: ../components/parameters/sessionId.yaml
responses:
"200":
description: Success
content:
application/json:
schema:
$ref: ../components/schemas/Session.yaml
"403":
description: Forbidden
$ref: ../components/responses/Problem.yaml
$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 94fbe98

Please sign in to comment.