Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OpenAPI 2 generator to produces vallid OpenAPI 2 #3

Merged
merged 4 commits into from
Nov 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions examples/src/single-file/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,9 @@ export interface CreateUserRequest {
name: string;
}

export type CreateUserResponse =
| {
success: false;
errors: string[];
}
| {
success: true;
confirmation: string;
};
export interface CreateUserResponse {
success: boolean;
}

export interface GetUserResponse {
name: string;
Expand Down
34 changes: 5 additions & 29 deletions lib/src/__snapshots__/parser.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -309,36 +309,12 @@ Object {
},
},
"CreateUserResponse": Object {
"kind": "union",
"types": Array [
Object {
"kind": "object",
"properties": Object {
"errors": Object {
"elements": Object {
"kind": "string",
},
"kind": "array",
},
"success": Object {
"kind": "boolean-constant",
"value": false,
},
},
},
Object {
"kind": "object",
"properties": Object {
"confirmation": Object {
"kind": "string",
},
"success": Object {
"kind": "boolean-constant",
"value": true,
},
},
"kind": "object",
"properties": Object {
"success": Object {
"kind": "boolean",
},
],
},
},
"GetUserResponse": Object {
"kind": "object",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,42 +84,14 @@ exports[`JSON Schema generator produces valid code single-file: json 1`] = `
]
},
\\"CreateUserResponse\\": {
\\"oneOf\\": [
{
\\"type\\": \\"object\\",
\\"properties\\": {
\\"success\\": {
\\"type\\": \\"boolean\\",
\\"const\\": false
},
\\"errors\\": {
\\"type\\": \\"array\\",
\\"items\\": {
\\"type\\": \\"string\\"
}
}
},
\\"required\\": [
\\"success\\",
\\"errors\\"
]
},
{
\\"type\\": \\"object\\",
\\"properties\\": {
\\"success\\": {
\\"type\\": \\"boolean\\",
\\"const\\": true
},
\\"confirmation\\": {
\\"type\\": \\"string\\"
}
},
\\"required\\": [
\\"success\\",
\\"confirmation\\"
]
\\"type\\": \\"object\\",
\\"properties\\": {
\\"success\\": {
\\"type\\": \\"boolean\\"
}
},
\\"required\\": [
\\"success\\"
]
},
\\"GetUserResponse\\": {
Expand Down Expand Up @@ -148,29 +120,12 @@ definitions:
required:
- name
CreateUserResponse:
oneOf:
- type: object
properties:
success:
type: boolean
const: false
errors:
type: array
items:
type: string
required:
- success
- errors
- type: object
properties:
success:
type: boolean
const: true
confirmation:
type: string
required:
- success
- confirmation
type: object
properties:
success:
type: boolean
required:
- success
GetUserResponse:
type: object
properties:
Expand Down
Loading