-
Notifications
You must be signed in to change notification settings - Fork 76
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): resolve parameter refs prior to parameter validation
It is legal to use $ref in parameters in an OpenAPI spec, but the validation was assuming these were not present. Updated the validation to work on a dereferenced clone of the spec. Ensured that the final parsed spec retains references to ensure the code generator can consolidate models. Fixes #590
- Loading branch information
Showing
4 changed files
with
137 additions
and
1 deletion.
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
39 changes: 39 additions & 0 deletions
39
packages/type-safe-api/test/resources/specs/parameter-refs.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,39 @@ | ||
openapi: 3.0.3 | ||
info: | ||
version: 1.0.0 | ||
title: Example API | ||
paths: | ||
/hello: | ||
get: | ||
operationId: sayHello | ||
x-handler: | ||
language: typescript | ||
parameters: | ||
- $ref: '#/components/parameters/HelloId' | ||
responses: | ||
'200': | ||
description: Successful response | ||
content: | ||
'application/json': | ||
schema: | ||
$ref: '#/components/schemas/HelloResponse' | ||
components: | ||
parameters: | ||
HelloId: | ||
in: query | ||
name: id | ||
schema: | ||
$ref: '#/components/schemas/HelloId' | ||
required: false | ||
schemas: | ||
HelloId: | ||
type: string | ||
HelloResponse: | ||
type: object | ||
properties: | ||
id: | ||
$ref: '#/components/schemas/HelloId' | ||
message: | ||
$ref: '#/components/schemas/HelloResponse' | ||
required: | ||
- id |
70 changes: 70 additions & 0 deletions
70
packages/type-safe-api/test/scripts/parser/__snapshots__/parse-openapi-spec.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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