-
-
Notifications
You must be signed in to change notification settings - Fork 272
feat: implement OpenAPI 3.1 patternProperties feature
#2523
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e2823f5
feat: implement OpenAPI 3.1 patternProperties feature
carson2222 7f6de44
test(parser): implementing testing for the new patternProperties keyword
carson2222 e831454
chore(plugin): remove a comment
carson2222 5556d0c
refactor(parser): remove parsePatternProperties function and related …
carson2222 666ccc5
Update two-humans-rescue.md
mrlubos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,5 @@ | ||
| --- | ||
| '@hey-api/openapi-ts': patch | ||
| --- | ||
|
|
||
| fix(parser): handle `patternProperties` in OpenAPI 3.1 |
This file contains hidden or 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
2 changes: 2 additions & 0 deletions
2
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pattern-properties/index.ts
This file contains hidden or 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,2 @@ | ||
| // This file is auto-generated by @hey-api/openapi-ts | ||
| export * from './types.gen'; |
56 changes: 56 additions & 0 deletions
56
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pattern-properties/types.gen.ts
This file contains hidden or 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,56 @@ | ||
| // This file is auto-generated by @hey-api/openapi-ts | ||
|
|
||
| export type PatternPropertiesTest = { | ||
| id?: string; | ||
| metadata?: MetadataObject; | ||
| }; | ||
|
|
||
| export type MetadataObject = { | ||
| name?: string; | ||
| description?: string; | ||
| [key: string]: Array<string> | string | { | ||
| value?: string; | ||
| enabled?: boolean; | ||
| } | undefined; | ||
| }; | ||
|
|
||
| export type NestedPatternObject = { | ||
| base?: string; | ||
| [key: string]: { | ||
| [key: string]: string; | ||
| } | string | undefined; | ||
| }; | ||
|
|
||
| export type UnionPatternObject = { | ||
| type?: 'user' | 'admin' | 'guest'; | ||
| [key: string]: ({ | ||
| [key: string]: unknown; | ||
| } & { | ||
| level?: number; | ||
| }) | (string | number) | ('user' | 'admin' | 'guest') | undefined; | ||
| }; | ||
|
|
||
| export type PatternPropertiesResponse = { | ||
| success?: boolean; | ||
| data?: MetadataObject; | ||
| }; | ||
|
|
||
| export type PostPatternTestData = { | ||
| body: PatternPropertiesTest; | ||
| path?: never; | ||
| query?: never; | ||
| url: '/pattern-test'; | ||
| }; | ||
|
|
||
| export type PostPatternTestResponses = { | ||
| /** | ||
| * Success | ||
| */ | ||
| 200: PatternPropertiesResponse; | ||
| }; | ||
|
|
||
| export type PostPatternTestResponse = PostPatternTestResponses[keyof PostPatternTestResponses]; | ||
|
|
||
| export type ClientOptions = { | ||
| baseUrl: `${string}://${string}` | (string & {}); | ||
| }; |
163 changes: 163 additions & 0 deletions
163
packages/openapi-ts-tests/specs/3.1.x/pattern-properties.json
This file contains hidden or 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,163 @@ | ||
| { | ||
| "openapi": "3.1.0", | ||
| "info": { | ||
| "title": "OpenAPI 3.1.0 pattern properties example", | ||
| "version": "1" | ||
| }, | ||
| "paths": { | ||
| "/pattern-test": { | ||
| "post": { | ||
| "summary": "Test pattern properties", | ||
| "requestBody": { | ||
| "required": true, | ||
| "content": { | ||
| "application/json": { | ||
| "schema": { | ||
| "$ref": "#/components/schemas/PatternPropertiesTest" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "responses": { | ||
| "200": { | ||
| "description": "Success", | ||
| "content": { | ||
| "application/json": { | ||
| "schema": { | ||
| "$ref": "#/components/schemas/PatternPropertiesResponse" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "components": { | ||
| "schemas": { | ||
| "PatternPropertiesTest": { | ||
| "type": "object", | ||
| "properties": { | ||
| "id": { | ||
| "type": "string" | ||
| }, | ||
| "metadata": { | ||
| "$ref": "#/components/schemas/MetadataObject" | ||
| } | ||
| }, | ||
| "additionalProperties": false | ||
| }, | ||
| "MetadataObject": { | ||
| "type": "object", | ||
| "properties": { | ||
| "name": { | ||
| "type": "string" | ||
| }, | ||
| "description": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "patternProperties": { | ||
| "^meta_": { | ||
| "type": "string", | ||
| "description": "Any property starting with 'meta_' must be a string" | ||
| }, | ||
| "^config_": { | ||
| "type": "object", | ||
| "properties": { | ||
| "value": { | ||
| "type": "string" | ||
| }, | ||
| "enabled": { | ||
| "type": "boolean" | ||
| } | ||
| }, | ||
| "additionalProperties": false | ||
| }, | ||
| "^tag_[a-zA-Z0-9_]+$": { | ||
| "type": "string", | ||
| "description": "Tag properties must match pattern and be strings" | ||
| }, | ||
| "^[0-9]+_item$": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "string" | ||
| }, | ||
| "description": "Numbered item properties must be arrays of strings" | ||
| } | ||
| }, | ||
| "additionalProperties": false | ||
| }, | ||
| "NestedPatternObject": { | ||
| "type": "object", | ||
| "properties": { | ||
| "base": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "patternProperties": { | ||
| "^nested_": { | ||
| "type": "object", | ||
| "patternProperties": { | ||
| "^sub_": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "additionalProperties": false | ||
| } | ||
| }, | ||
| "additionalProperties": false | ||
| }, | ||
| "UnionPatternObject": { | ||
| "type": "object", | ||
| "properties": { | ||
| "type": { | ||
| "type": "string", | ||
| "enum": ["user", "admin", "guest"] | ||
| } | ||
| }, | ||
| "patternProperties": { | ||
| "^user_": { | ||
| "oneOf": [ | ||
| { | ||
| "type": "string" | ||
| }, | ||
| { | ||
| "type": "number" | ||
| } | ||
| ] | ||
| }, | ||
| "^admin_": { | ||
| "allOf": [ | ||
| { | ||
| "type": "object" | ||
| }, | ||
| { | ||
| "properties": { | ||
| "level": { | ||
| "type": "number", | ||
| "minimum": 1, | ||
| "maximum": 10 | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| "additionalProperties": false | ||
| }, | ||
| "PatternPropertiesResponse": { | ||
| "type": "object", | ||
| "properties": { | ||
| "success": { | ||
| "type": "boolean" | ||
| }, | ||
| "data": { | ||
| "$ref": "#/components/schemas/MetadataObject" | ||
| } | ||
| }, | ||
| "additionalProperties": false | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.