-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cli): openapi importer supports a setting for not defaulting opti…
…onal additional properties
- Loading branch information
Showing
15 changed files
with
285 additions
and
20 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
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
22 changes: 20 additions & 2 deletions
22
packages/cli/configuration/src/generators-yml/schemas/APIConfigurationV2Schema.ts
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
183 changes: 183 additions & 0 deletions
183
packages/cli/openapi-parser/src/__test__/__snapshots__/additionalProperties.test.ts.snap
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,183 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`anyOf > additional-properties > parse open api 1`] = ` | ||
{ | ||
"apiVersion": null, | ||
"basePath": null, | ||
"channel": [], | ||
"description": null, | ||
"endpoints": [], | ||
"globalHeaders": [], | ||
"groups": {}, | ||
"hasEndpointsMarkedInternal": false, | ||
"idempotencyHeaders": [], | ||
"nonRequestReferencedSchemas": [], | ||
"schemas": { | ||
"CheckFlagRequestBody": { | ||
"additionalProperties": false, | ||
"allOf": [], | ||
"allOfPropertyConflicts": [], | ||
"availability": null, | ||
"description": null, | ||
"generatedName": "CheckFlagRequestBody", | ||
"groupName": [], | ||
"nameOverride": null, | ||
"properties": [ | ||
{ | ||
"audiences": [], | ||
"availability": null, | ||
"conflict": {}, | ||
"generatedName": "checkFlagRequestBodyCompany", | ||
"key": "company", | ||
"nameOverride": null, | ||
"schema": { | ||
"availability": null, | ||
"description": null, | ||
"generatedName": "checkFlagRequestBodyCompany", | ||
"groupName": [], | ||
"nameOverride": null, | ||
"title": null, | ||
"type": "optional", | ||
"value": { | ||
"availability": null, | ||
"description": null, | ||
"generatedName": "CheckFlagRequestBodyCompany", | ||
"groupName": [], | ||
"nameOverride": null, | ||
"title": null, | ||
"type": "nullable", | ||
"value": { | ||
"availability": null, | ||
"description": null, | ||
"encoding": null, | ||
"generatedName": "CheckFlagRequestBodyCompany", | ||
"groupName": [], | ||
"key": { | ||
"availability": null, | ||
"description": null, | ||
"generatedName": "CheckFlagRequestBodyCompanyKey", | ||
"groupName": [], | ||
"nameOverride": null, | ||
"schema": { | ||
"default": null, | ||
"format": null, | ||
"maxLength": null, | ||
"minLength": null, | ||
"pattern": null, | ||
"type": "string", | ||
}, | ||
"title": null, | ||
}, | ||
"nameOverride": null, | ||
"title": null, | ||
"type": "map", | ||
"value": { | ||
"availability": null, | ||
"description": null, | ||
"generatedName": "CheckFlagRequestBodyCompanyValue", | ||
"groupName": [], | ||
"nameOverride": null, | ||
"schema": { | ||
"default": null, | ||
"format": null, | ||
"maxLength": null, | ||
"minLength": null, | ||
"pattern": null, | ||
"type": "string", | ||
}, | ||
"title": null, | ||
"type": "primitive", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
"audiences": [], | ||
"availability": null, | ||
"conflict": {}, | ||
"generatedName": "checkFlagRequestBodyUser", | ||
"key": "user", | ||
"nameOverride": null, | ||
"schema": { | ||
"availability": null, | ||
"description": null, | ||
"generatedName": "checkFlagRequestBodyUser", | ||
"groupName": [], | ||
"nameOverride": null, | ||
"title": null, | ||
"type": "optional", | ||
"value": { | ||
"availability": null, | ||
"description": null, | ||
"generatedName": "CheckFlagRequestBodyUser", | ||
"groupName": [], | ||
"nameOverride": null, | ||
"title": null, | ||
"type": "nullable", | ||
"value": { | ||
"availability": null, | ||
"description": null, | ||
"encoding": null, | ||
"generatedName": "CheckFlagRequestBodyUser", | ||
"groupName": [], | ||
"key": { | ||
"availability": null, | ||
"description": null, | ||
"generatedName": "CheckFlagRequestBodyUserKey", | ||
"groupName": [], | ||
"nameOverride": null, | ||
"schema": { | ||
"default": null, | ||
"format": null, | ||
"maxLength": null, | ||
"minLength": null, | ||
"pattern": null, | ||
"type": "string", | ||
}, | ||
"title": null, | ||
}, | ||
"nameOverride": null, | ||
"title": null, | ||
"type": "map", | ||
"value": { | ||
"availability": null, | ||
"description": null, | ||
"generatedName": "CheckFlagRequestBodyUserValue", | ||
"groupName": [], | ||
"nameOverride": null, | ||
"schema": { | ||
"default": null, | ||
"format": null, | ||
"maxLength": null, | ||
"minLength": null, | ||
"pattern": null, | ||
"type": "string", | ||
}, | ||
"title": null, | ||
"type": "primitive", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
"source": { | ||
"file": "additional-properties/openapi.yml", | ||
"type": "openapi", | ||
}, | ||
"title": null, | ||
"type": "object", | ||
}, | ||
}, | ||
"securitySchemes": {}, | ||
"servers": [], | ||
"tags": { | ||
"orderedTagIds": null, | ||
"tagsById": {}, | ||
}, | ||
"title": "Additional Properties", | ||
"variables": {}, | ||
"webhooks": [], | ||
} | ||
`; |
10 changes: 10 additions & 0 deletions
10
packages/cli/openapi-parser/src/__test__/additionalProperties.test.ts
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,10 @@ | ||
import { testParseOpenAPI } from "./testParseOpenApi"; | ||
|
||
describe("anyOf", () => { | ||
testParseOpenAPI("additional-properties", "openapi.yml", undefined, { | ||
audiences: [], | ||
shouldUseTitleAsName: true, | ||
shouldUseUndiscriminatedUnionsWithLiterals: true, | ||
optionalAdditionalProperties: false | ||
}); | ||
}); |
21 changes: 21 additions & 0 deletions
21
packages/cli/openapi-parser/src/__test__/fixtures/additional-properties/openapi.yml
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,21 @@ | ||
openapi: 3.1.0 | ||
info: | ||
title: Additional Properties | ||
version: "0" | ||
paths: {} | ||
components: | ||
schemas: | ||
CheckFlagRequestBody: | ||
type: object | ||
properties: | ||
company: | ||
additionalProperties: | ||
type: string | ||
type: object | ||
nullable: true | ||
user: | ||
additionalProperties: | ||
type: string | ||
type: object | ||
nullable: true | ||
|
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
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
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
Oops, something went wrong.