-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Remove duplicate oneOf schemas during pre-processing #21174
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 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0d0a3d0
fix: Remove duplicate oneOf schemas during pre-processing
ranger-ross e0977a3
chore: Updated samples
ranger-ross cc880bd
fix: Fixed regression with oneOf+discriminator
ranger-ross af498c5
fix: Fixed possible null pointer during schema preprocessing
ranger-ross ba437f3
refactor: Moved oneOf deduplication to OpenAPINormalizer
ranger-ross 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
11 changes: 11 additions & 0 deletions
11
samples/client/petstore/rust/hyper/petstore/docs/DuplicateOneOf.md
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,11 @@ | ||
# DuplicateOneOf | ||
|
||
## Enum Variants | ||
|
||
| Name | Description | | ||
|---- | -----| | ||
| Order | | | ||
|
||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) | ||
|
||
|
11 changes: 11 additions & 0 deletions
11
samples/client/petstore/rust/hyper/petstore/docs/WithInnerOneOf.md
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,11 @@ | ||
# WithInnerOneOf | ||
|
||
## Properties | ||
|
||
Name | Type | Description | Notes | ||
------------ | ------------- | ------------- | ------------- | ||
**foo** | Option<[**models::WithInnerOneOfFoo**](WithInnerOneOf_foo.md)> | | [optional] | ||
|
||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) | ||
|
||
|
11 changes: 11 additions & 0 deletions
11
samples/client/petstore/rust/hyper/petstore/docs/WithInnerOneOfFoo.md
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,11 @@ | ||
# WithInnerOneOfFoo | ||
|
||
## Enum Variants | ||
|
||
| Name | Description | | ||
|---- | -----| | ||
| Order | | | ||
|
||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) | ||
|
||
|
41 changes: 41 additions & 0 deletions
41
samples/client/petstore/rust/hyper/petstore/src/models/duplicate_one_of.rs
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,41 @@ | ||
/* | ||
* OpenAPI Petstore | ||
* | ||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. | ||
* | ||
* The version of the OpenAPI document: 1.0.0 | ||
* | ||
* Generated by: https://openapi-generator.tech | ||
*/ | ||
|
||
use crate::models; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] | ||
#[serde(untagged)] | ||
pub enum DuplicateOneOf { | ||
Order(Box<models::Order>), | ||
} | ||
|
||
impl Default for DuplicateOneOf { | ||
fn default() -> Self { | ||
Self::Order(Default::default()) | ||
} | ||
} | ||
/// Order Status | ||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] | ||
pub enum Status { | ||
#[serde(rename = "placed")] | ||
Placed, | ||
#[serde(rename = "approved")] | ||
Approved, | ||
#[serde(rename = "delivered")] | ||
Delivered, | ||
} | ||
|
||
impl Default for Status { | ||
fn default() -> Status { | ||
Self::Placed | ||
} | ||
} | ||
|
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
27 changes: 27 additions & 0 deletions
27
samples/client/petstore/rust/hyper/petstore/src/models/with_inner_one_of.rs
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,27 @@ | ||
/* | ||
* OpenAPI Petstore | ||
* | ||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. | ||
* | ||
* The version of the OpenAPI document: 1.0.0 | ||
* | ||
* Generated by: https://openapi-generator.tech | ||
*/ | ||
|
||
use crate::models; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] | ||
pub struct WithInnerOneOf { | ||
#[serde(rename = "foo", skip_serializing_if = "Option::is_none")] | ||
pub foo: Option<Box<models::WithInnerOneOfFoo>>, | ||
} | ||
|
||
impl WithInnerOneOf { | ||
pub fn new() -> WithInnerOneOf { | ||
WithInnerOneOf { | ||
foo: None, | ||
} | ||
} | ||
} | ||
|
41 changes: 41 additions & 0 deletions
41
samples/client/petstore/rust/hyper/petstore/src/models/with_inner_one_of_foo.rs
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,41 @@ | ||
/* | ||
* OpenAPI Petstore | ||
* | ||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. | ||
* | ||
* The version of the OpenAPI document: 1.0.0 | ||
* | ||
* Generated by: https://openapi-generator.tech | ||
*/ | ||
|
||
use crate::models; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] | ||
#[serde(untagged)] | ||
pub enum WithInnerOneOfFoo { | ||
Order(Box<models::Order>), | ||
} | ||
|
||
impl Default for WithInnerOneOfFoo { | ||
fn default() -> Self { | ||
Self::Order(Default::default()) | ||
} | ||
} | ||
/// Order Status | ||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] | ||
pub enum Status { | ||
#[serde(rename = "placed")] | ||
Placed, | ||
#[serde(rename = "approved")] | ||
Approved, | ||
#[serde(rename = "delivered")] | ||
Delivered, | ||
} | ||
|
||
impl Default for Status { | ||
fn default() -> Status { | ||
Self::Placed | ||
} | ||
} | ||
|
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
11 changes: 11 additions & 0 deletions
11
samples/client/petstore/rust/hyper0x/petstore/docs/DuplicateOneOf.md
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,11 @@ | ||
# DuplicateOneOf | ||
|
||
## Enum Variants | ||
|
||
| Name | Description | | ||
|---- | -----| | ||
| Order | | | ||
|
||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) | ||
|
||
|
11 changes: 11 additions & 0 deletions
11
samples/client/petstore/rust/hyper0x/petstore/docs/WithInnerOneOf.md
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,11 @@ | ||
# WithInnerOneOf | ||
|
||
## Properties | ||
|
||
Name | Type | Description | Notes | ||
------------ | ------------- | ------------- | ------------- | ||
**foo** | Option<[**models::WithInnerOneOfFoo**](WithInnerOneOf_foo.md)> | | [optional] | ||
|
||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) | ||
|
||
|
11 changes: 11 additions & 0 deletions
11
samples/client/petstore/rust/hyper0x/petstore/docs/WithInnerOneOfFoo.md
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,11 @@ | ||
# WithInnerOneOfFoo | ||
|
||
## Enum Variants | ||
|
||
| Name | Description | | ||
|---- | -----| | ||
| Order | | | ||
|
||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) | ||
|
||
|
41 changes: 41 additions & 0 deletions
41
samples/client/petstore/rust/hyper0x/petstore/src/models/duplicate_one_of.rs
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,41 @@ | ||
/* | ||
* OpenAPI Petstore | ||
* | ||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. | ||
* | ||
* The version of the OpenAPI document: 1.0.0 | ||
* | ||
* Generated by: https://openapi-generator.tech | ||
*/ | ||
|
||
use crate::models; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] | ||
#[serde(untagged)] | ||
pub enum DuplicateOneOf { | ||
Order(Box<models::Order>), | ||
} | ||
|
||
impl Default for DuplicateOneOf { | ||
fn default() -> Self { | ||
Self::Order(Default::default()) | ||
} | ||
} | ||
/// Order Status | ||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] | ||
pub enum Status { | ||
#[serde(rename = "placed")] | ||
Placed, | ||
#[serde(rename = "approved")] | ||
Approved, | ||
#[serde(rename = "delivered")] | ||
Delivered, | ||
} | ||
|
||
impl Default for Status { | ||
fn default() -> Status { | ||
Self::Placed | ||
} | ||
} | ||
|
Oops, something went wrong.
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.
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.
what about doing this in the normalizer instead when looping through all schemas?
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.
Thanks, good call.
If we do that, we can deduplicate before calling
processSimplifyOneOf()
which will help further simplify the models :)