-
Notifications
You must be signed in to change notification settings - Fork 51
Add subschemas #22
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
Open
pickfire
wants to merge
1
commit into
higress-group:main
Choose a base branch
from
pickfire:subschemas
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add subschemas #22
Changes from all commits
Commits
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
Some comments aren't visible on the classic Files Changed page.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| server: | ||
| name: openapi-server | ||
| tools: | ||
| - name: post_user | ||
| description: Test allOf, anyOf, and oneOf in request body | ||
| args: | ||
| - name: allOfUser | ||
| description: Combines both BaseUser and ExtraInfo via allOf | ||
| type: object | ||
| position: body | ||
| - name: anyOfUser | ||
| description: Valid if matches any of BaseUser or ExtraInfo | ||
| type: object | ||
| position: body | ||
| - name: oneOfUser | ||
| description: Valid if matches exactly one of BaseUser or ExtraInfo | ||
| type: object | ||
| position: body | ||
| requestTemplate: | ||
| url: /user | ||
| method: POST | ||
| headers: | ||
| - key: Content-Type | ||
| value: application/json | ||
| responseTemplate: {} |
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,99 @@ | ||
| { | ||
| "openapi": "3.0.3", | ||
| "info": { | ||
| "title": "Composition Test API", | ||
| "version": "1.0.0" | ||
| }, | ||
| "paths": { | ||
| "/user": { | ||
| "post": { | ||
| "summary": "Test allOf, anyOf, and oneOf in request body", | ||
| "requestBody": { | ||
| "required": true, | ||
| "content": { | ||
| "application/json": { | ||
| "schema": { | ||
| "$ref": "#/components/schemas/CompositionTest" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "responses": { | ||
| "200": { | ||
| "description": "OK" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "components": { | ||
| "schemas": { | ||
| "CompositionTest": { | ||
| "type": "object", | ||
| "properties": { | ||
| "allOfUser": { | ||
| "description": "Combines both BaseUser and ExtraInfo via allOf", | ||
| "allOf": [ | ||
| { | ||
| "$ref": "#/components/schemas/BaseUser" | ||
| }, | ||
| { | ||
| "$ref": "#/components/schemas/ExtraInfo" | ||
| } | ||
| ] | ||
| }, | ||
| "anyOfUser": { | ||
| "description": "Valid if matches any of BaseUser or ExtraInfo", | ||
| "anyOf": [ | ||
| { | ||
| "$ref": "#/components/schemas/BaseUser" | ||
| }, | ||
| { | ||
| "$ref": "#/components/schemas/ExtraInfo" | ||
| } | ||
| ] | ||
| }, | ||
| "oneOfUser": { | ||
| "description": "Valid if matches exactly one of BaseUser or ExtraInfo", | ||
| "oneOf": [ | ||
| { | ||
| "$ref": "#/components/schemas/BaseUser" | ||
| }, | ||
| { | ||
| "$ref": "#/components/schemas/ExtraInfo" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| }, | ||
| "BaseUser": { | ||
| "type": "object", | ||
| "properties": { | ||
| "id": { | ||
| "type": "integer" | ||
| }, | ||
| "name": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "required": [ | ||
| "id", | ||
| "name" | ||
| ] | ||
| }, | ||
| "ExtraInfo": { | ||
| "type": "object", | ||
| "properties": { | ||
| "email": { | ||
| "type": "string", | ||
| "format": "email" | ||
| }, | ||
| "age": { | ||
| "type": "integer", | ||
| "minimum": 0 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
新增的
hasCommonType函数逻辑不完整,仅比较类型是否一致,未考虑其他属性如格式、枚举等。📋 问题详情
该函数用于判断一组 schema 是否具有相同的类型,但实际在 OpenAPI 规范中,即使类型相同,格式(如
string+email)或枚举值不同也会导致语义不同。当前实现可能误判,导致错误的类型合并。💡 解决方案
建议增强
hasCommonType函数,不仅比较Type,还应考虑Format、Enum等关键属性,确保语义一致性。有用意见👍 | 无用意见👎 | 错误意见❌