-
-
Notifications
You must be signed in to change notification settings - Fork 415
Avoid mixing up configurations of different objects with the same name #2461
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
gaborbernat
merged 9 commits into
koxudaxi:main
from
ilovelinux:fix/ilovelinux-2460-same-name-objects
Aug 3, 2025
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d51f978
Create test for jsonschema
ilovelinux 63e7854
Add test for OpenAPI
ilovelinux d99998b
Fix bug
ilovelinux 68ee239
Fix test
ilovelinux 94b06e5
Improve documentation
ilovelinux dca2a51
Update README.md
ilovelinux 5da1992
Update command cli documentation
ilovelinux a8810d1
Use tmp_path fixture instead of TemporaryDirectory
ilovelinux 96bfcc2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 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
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
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,32 @@ | ||
| # generated by datamodel-codegen: | ||
| # filename: same_name_objects.json | ||
| # timestamp: 2019-07-26T00:00:00+00:00 | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import Any, List | ||
|
|
||
| from pydantic import BaseModel, Extra | ||
|
|
||
|
|
||
| class Model(BaseModel): | ||
| __root__: Any | ||
|
|
||
|
|
||
| class Friends(BaseModel): | ||
| pass | ||
|
|
||
| class Config: | ||
| extra = Extra.forbid | ||
|
|
||
|
|
||
| class FriendsModel(BaseModel): | ||
| __root__: List | ||
|
|
||
|
|
||
| class Tst2(BaseModel): | ||
| __root__: FriendsModel | ||
|
|
||
|
|
||
| class Tst1(BaseModel): | ||
| __root__: FriendsModel | ||
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,43 @@ | ||
| # generated by datamodel-codegen: | ||
| # filename: same_name_objects.yaml | ||
| # timestamp: 2019-07-26T00:00:00+00:00 | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import List, Optional | ||
|
|
||
| from pydantic import BaseModel, Extra | ||
|
|
||
|
|
||
| class Pets(BaseModel): | ||
| pass | ||
Check warningCode scanning / CodeQL Unnecessary pass Warning test
Unnecessary 'pass' statement.
|
||
|
|
||
| class Config: | ||
| extra = Extra.forbid | ||
|
|
||
|
|
||
| class Pet(BaseModel): | ||
| id: int | ||
| name: str | ||
| tag: Optional[str] = None | ||
|
|
||
|
|
||
| class Error(BaseModel): | ||
| code: int | ||
| message: str | ||
|
|
||
|
|
||
| class Resolved(BaseModel): | ||
| resolved: Optional[List[str]] = None | ||
|
|
||
|
|
||
| class PetsModel(BaseModel): | ||
| __root__: List[Pet] | ||
|
|
||
|
|
||
| class Friends2(BaseModel): | ||
| __root__: PetsModel | ||
|
|
||
|
|
||
| class Friends1(BaseModel): | ||
| __root__: PetsModel | ||
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,16 @@ | ||
| { | ||
| "$id": "https://example.com/same_name_objects.json", | ||
| "$schema": "http://json-schema.org/draft-07/schema#", | ||
| "definitions": { | ||
| "friends": { | ||
| "type": "object", | ||
| "additionalProperties": false | ||
| }, | ||
| "tst1": { | ||
| "$ref": "person.json#/properties/friends" | ||
| }, | ||
| "tst2": { | ||
| "$ref": "person.json#/properties/friends" | ||
| } | ||
| } | ||
| } |
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,15 @@ | ||
| openapi: "3.0.0" | ||
| info: | ||
| version: 1.0.0 | ||
| title: Swagger Petstore | ||
| license: | ||
| name: MIT | ||
| components: | ||
| schemas: | ||
| Pets: | ||
| type: object | ||
| additionalProperties: false | ||
| Friends1: | ||
| $ref: "resolved_models.yaml#/components/schemas/Pets" | ||
| Friends2: | ||
| $ref: "resolved_models.yaml#/components/schemas/Pets" |
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.
Check warning
Code scanning / CodeQL
Unnecessary pass Warning test