-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(type-safe-api): fix several regressions in the new code generation (
#845) * fix(type-safe-api): add missing imports for parameter models Parameter models were not being imported in the API client in the typescript runtime. References #841 * fix(type-safe-api): fix duplicate 200 response for operations with default responses OpenAPI generator treated "default" responses as responses with code 0, however parseOpenapi treats default as 200. Adjust code generation to follow OpenAPI for backwards compatibility and to avoid duplicate 200 responses. Note that this should be revisited such that code generation allows for any response code other than those defined to be returned for the default response, rather than 0. References #841 * fix(type-safe-api): add missing imports for composed models Composed models (using all-of, one-of or any-of) are generated as "mixins" rather than using inheritance, to match openapi generator's behaviour. We therefore need to ensure models import all types from the composed properties. References #841
- Loading branch information
Showing
5 changed files
with
6,056 additions
and
1,572 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
54 changes: 54 additions & 0 deletions
54
packages/type-safe-api/test/resources/specs/allof-model.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,54 @@ | ||
openapi: 3.0.3 | ||
info: | ||
version: 1.0.0 | ||
title: My API | ||
description: See https://github.com/aws/aws-pdk/issues/841 | ||
paths: | ||
/hello: | ||
get: | ||
operationId: sayHello | ||
responses: | ||
200: | ||
description: Successful response | ||
content: | ||
'application/json': | ||
schema: | ||
$ref: '#/components/schemas/Template' | ||
components: | ||
schemas: | ||
Template: | ||
allOf: | ||
- $ref: '#/components/schemas/TemplateBase' | ||
- $ref: '#/components/schemas/TemplateBody' | ||
- title: Template | ||
description: | | ||
Represents a complete template in the system. | ||
TemplateBase: | ||
type: object | ||
title: TemplateBase | ||
description: | | ||
Represents the base properties of a template. | ||
additionalProperties: false | ||
required: | ||
- id | ||
properties: | ||
id: | ||
$ref: '#/components/schemas/TemplateID' | ||
TemplateBody: | ||
type: object | ||
title: TemplateBody | ||
description: | | ||
Represents the body of a template. | ||
additionalProperties: false | ||
properties: | ||
parent_id: | ||
$ref: '#/components/schemas/TemplateID' | ||
boolean: | ||
type: boolean | ||
description: A boolean value. | ||
TemplateID: | ||
type: string | ||
format: uuid | ||
title: TemplateID | ||
description: The unique identifier for a template. | ||
maxLength: 36 |
51 changes: 51 additions & 0 deletions
51
packages/type-safe-api/test/resources/specs/default-response.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,51 @@ | ||
openapi: 3.0.3 | ||
info: | ||
version: 1.0.0 | ||
title: My API | ||
description: See https://github.com/aws/aws-pdk/issues/841 | ||
paths: | ||
/hello: | ||
get: | ||
operationId: sayHello | ||
x-handler: | ||
language: typescript | ||
parameters: | ||
- in: query | ||
name: name | ||
schema: | ||
type: string | ||
required: true | ||
responses: | ||
200: | ||
description: Successful response | ||
content: | ||
'application/json': | ||
schema: | ||
$ref: '#/components/schemas/SayHelloResponseContent' | ||
default: | ||
description: An error due to the client not being authorized to access the resource | ||
content: | ||
'application/json': | ||
schema: | ||
$ref: '#/components/schemas/ServiceUnavailableErrorResponseContent' | ||
components: | ||
schemas: | ||
SayHelloResponseContent: | ||
type: object | ||
properties: | ||
id: | ||
$ref: '#/components/schemas/HelloId' | ||
message: | ||
type: string | ||
required: | ||
- message | ||
HelloId: | ||
type: string | ||
format: uuid | ||
ServiceUnavailableErrorResponseContent: | ||
type: object | ||
properties: | ||
message: | ||
type: string | ||
required: | ||
- message |
Oops, something went wrong.