-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
43557d1
commit 80043d5
Showing
3 changed files
with
248 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
173 changes: 173 additions & 0 deletions
173
.../src/test/resources/ballerina-to-openapi/expected_gen/response/status_code_errors_03.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
openapi: 3.0.1 | ||
info: | ||
title: PayloadV | ||
version: 0.0.0 | ||
servers: | ||
- url: "{server}:{port}/payloadV" | ||
variables: | ||
server: | ||
default: http://localhost | ||
port: | ||
default: "9000" | ||
paths: | ||
/users/{id}: | ||
get: | ||
operationId: getUsersId | ||
parameters: | ||
- name: id | ||
in: path | ||
required: true | ||
schema: | ||
type: integer | ||
format: int64 | ||
responses: | ||
"200": | ||
description: Ok | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/User' | ||
"202": | ||
description: Accepted | ||
"404": | ||
description: NotFound | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/UserApiErrorInfo' | ||
"400": | ||
description: BadRequest | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/ErrorPayload' | ||
/users: | ||
post: | ||
operationId: postUsers | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/UserWithoutId' | ||
required: true | ||
responses: | ||
"201": | ||
description: Created | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/User' | ||
"400": | ||
description: BadRequest | ||
content: | ||
application/json: | ||
schema: | ||
oneOf: | ||
- $ref: '#/components/schemas/UserApiErrorInfo' | ||
- $ref: '#/components/schemas/ErrorPayload' | ||
"202": | ||
description: Accepted | ||
"409": | ||
description: Conflict | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/UserApiErrorInfo' | ||
/test1: | ||
get: | ||
operationId: getTest1 | ||
responses: | ||
default: | ||
description: Any Response | ||
content: | ||
'*/*': | ||
schema: | ||
description: Any type of entity body | ||
"202": | ||
description: Accepted | ||
/test2: | ||
get: | ||
operationId: getTest2 | ||
responses: | ||
default: | ||
description: Any Response | ||
content: | ||
'*/*': | ||
schema: | ||
description: Any type of entity body | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/DefaultErrorInfo' | ||
"202": | ||
description: Accepted | ||
components: | ||
schemas: | ||
DefaultErrorInfo: | ||
required: | ||
- message | ||
- timeStamp | ||
type: object | ||
properties: | ||
timeStamp: | ||
type: string | ||
message: | ||
type: string | ||
additionalProperties: false | ||
ErrorPayload: | ||
required: | ||
- message | ||
- method | ||
- path | ||
- reason | ||
- status | ||
- timestamp | ||
type: object | ||
properties: | ||
timestamp: | ||
type: string | ||
status: | ||
type: integer | ||
format: int64 | ||
reason: | ||
type: string | ||
message: | ||
type: string | ||
path: | ||
type: string | ||
method: | ||
type: string | ||
User: | ||
type: object | ||
allOf: | ||
- $ref: '#/components/schemas/UserWithoutId' | ||
- required: | ||
- id | ||
type: object | ||
properties: | ||
id: | ||
type: integer | ||
format: int64 | ||
additionalProperties: false | ||
UserApiErrorInfo: | ||
type: object | ||
allOf: | ||
- $ref: '#/components/schemas/DefaultErrorInfo' | ||
- required: | ||
- userId | ||
type: object | ||
properties: | ||
userId: | ||
type: string | ||
additionalProperties: false | ||
UserWithoutId: | ||
required: | ||
- age | ||
- name | ||
type: object | ||
properties: | ||
name: | ||
type: string | ||
age: | ||
type: integer | ||
format: int64 | ||
additionalProperties: false |
65 changes: 65 additions & 0 deletions
65
openapi-cli/src/test/resources/ballerina-to-openapi/response/status_code_errors_03.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import ballerina/http; | ||
import ballerina/http.httpscerr; | ||
|
||
type Error distinct error; | ||
|
||
type DefaultErrorInfo record {| | ||
string timeStamp; | ||
string message; | ||
|}; | ||
|
||
type DefaultErrorDetails record {| | ||
*httpscerr:ErrorDetail; | ||
DefaultErrorInfo body; | ||
|}; | ||
|
||
type UserApiErrorInfo record {| | ||
*DefaultErrorInfo; | ||
string userId; | ||
|}; | ||
|
||
type UserApiErrorDetails record {| | ||
*httpscerr:ErrorDetail; | ||
UserApiErrorInfo body; | ||
|}; | ||
|
||
type UserNotFoundError Error & httpscerr:NotFoundError & error<UserApiErrorDetails>; | ||
|
||
type UserNameAlreadyExistError Error & httpscerr:ConflictError & error<UserApiErrorDetails>; | ||
|
||
type BadUserError Error & httpscerr:BadRequestError & error<UserApiErrorDetails>; | ||
|
||
type DefaultError Error & httpscerr:DefaultStatusCodeError & error<DefaultErrorDetails>; | ||
|
||
type User record {| | ||
readonly int id; | ||
*UserWithoutId; | ||
|}; | ||
|
||
type UserWithoutId record {| | ||
string name; | ||
int age; | ||
|}; | ||
|
||
service /payloadV on new http:Listener(9000) { | ||
|
||
resource function get users/[int id]() returns User|UserNotFoundError? { | ||
return; | ||
} | ||
|
||
resource function post users(@http:Payload readonly & UserWithoutId user) | ||
returns User|UserNameAlreadyExistError|BadUserError? { | ||
return; | ||
} | ||
|
||
resource function get test1() returns http:Response|httpscerr:DefaultStatusCodeError? { | ||
return; | ||
} | ||
|
||
resource function get test2() returns http:Response|DefaultError? { | ||
return; | ||
} | ||
|
||
resource function 'default [string... path]() returns httpscerr:NotFoundError? { | ||
} | ||
} |