Skip to content

Set REFACTOR_ALLOF_WITH_PROPERTIES_ONLY to true by default #18238

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

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ OpenAPI Normalizer transforms the input OpenAPI doc/spec (which may not perfectl

- SIMPLIFY_ONEOF_ANYOF
- SIMPLIFY_BOOLEAN_ENUM
- REFACTOR_ALLOF_WITH_PROPERTIES_ONLY

(One can use `DISABLE_ALL=true` to disable all the rules)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ public OpenAPINormalizer(OpenAPI openAPI, Map<String, String> inputRules) {
// rules that are default to true
rules.put(SIMPLIFY_ONEOF_ANYOF, true);
rules.put(SIMPLIFY_BOOLEAN_ENUM, true);
rules.put(REFACTOR_ALLOF_WITH_PROPERTIES_ONLY, true); // default to true since v7.7.0

processRules(inputRules);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4589,8 +4589,11 @@ public void testMultiInheritanceParentRequiredParams_issue16797() throws IOExcep
// public Object4(Type1 pageInfo, String responseType, String requestId, Boolean success) {
// super(responseType, requestId, success, pageInfo);
// }
// UPDATE: with https://github.com/OpenAPITools/openapi-generator/pull/18238
// (REFACTOR_ALLOF_WITH_PROPERTIES_ONLY default to true)
// public Object4(String responseType, String requestId, Boolean success, Type1 pageInfo)
JavaFileAssert.assertThat(output.get("Object4.java"))
.assertConstructor("Type1", "String", "String", "Boolean")
.assertConstructor("String", "String", "Boolean", "Type1")
.hasParameter("responseType").toConstructor()
.hasParameter("requestId").toConstructor()
.hasParameter("success").toConstructor()
Expand Down
8 changes: 4 additions & 4 deletions samples/client/others/rust/hyper/oneOf/docs/Bar.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **String** | |
**bar_prop_a** | Option<**String**> | | [optional]
**foo_prop_b** | Option<**String**> | | [optional]
**foo** | Option<[**models::FooRefOrValue**](FooRefOrValue.md)> | | [optional]
**href** | Option<**String**> | Hyperlink reference | [optional]
**id** | **String** | |
**at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional]
**at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional]
**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name |
**bar_prop_a** | Option<**String**> | | [optional]
**foo_prop_b** | Option<**String**> | | [optional]
**foo** | Option<[**models::FooRefOrValue**](FooRefOrValue.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)

Expand Down
6 changes: 3 additions & 3 deletions samples/client/others/rust/hyper/oneOf/docs/BarCreate.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**bar_prop_a** | Option<**String**> | | [optional]
**foo_prop_b** | Option<**String**> | | [optional]
**foo** | Option<[**models::FooRefOrValue**](FooRefOrValue.md)> | | [optional]
**href** | Option<**String**> | Hyperlink reference | [optional]
**id** | Option<**String**> | unique identifier | [optional]
**at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional]
**at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional]
**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name |
**bar_prop_a** | Option<**String**> | | [optional]
**foo_prop_b** | Option<**String**> | | [optional]
**foo** | Option<[**models::FooRefOrValue**](FooRefOrValue.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)

Expand Down
4 changes: 2 additions & 2 deletions samples/client/others/rust/hyper/oneOf/docs/BarRef.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | Option<**String**> | Name of the related entity. | [optional]
**at_referred_type** | Option<**String**> | The actual type of the target instance when needed for disambiguation. | [optional]
**href** | Option<**String**> | Hyperlink reference | [optional]
**id** | Option<**String**> | unique identifier | [optional]
**at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional]
**at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional]
**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name |
**name** | Option<**String**> | Name of the related entity. | [optional]
**at_referred_type** | Option<**String**> | The actual type of the target instance when needed for disambiguation. | [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)

Expand Down
4 changes: 2 additions & 2 deletions samples/client/others/rust/hyper/oneOf/docs/Foo.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**foo_prop_a** | Option<**String**> | | [optional]
**foo_prop_b** | Option<**String**> | | [optional]
**href** | Option<**String**> | Hyperlink reference | [optional]
**id** | Option<**String**> | unique identifier | [optional]
**at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional]
**at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional]
**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name |
**foo_prop_a** | Option<**String**> | | [optional]
**foo_prop_b** | Option<**String**> | | [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)

Expand Down
6 changes: 3 additions & 3 deletions samples/client/others/rust/hyper/oneOf/docs/FooRef.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**fooref_prop_a** | Option<**String**> | | [optional]
**name** | Option<**String**> | Name of the related entity. | [optional]
**at_referred_type** | Option<**String**> | The actual type of the target instance when needed for disambiguation. | [optional]
**href** | Option<**String**> | Hyperlink reference | [optional]
**id** | Option<**String**> | unique identifier | [optional]
**at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional]
**at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional]
**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name |
**name** | Option<**String**> | Name of the related entity. | [optional]
**at_referred_type** | Option<**String**> | The actual type of the target instance when needed for disambiguation. | [optional]
**fooref_prop_a** | Option<**String**> | | [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)

Expand Down
2 changes: 1 addition & 1 deletion samples/client/others/rust/hyper/oneOf/docs/Pasta.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**vendor** | Option<**String**> | | [optional]
**href** | Option<**String**> | Hyperlink reference | [optional]
**id** | Option<**String**> | unique identifier | [optional]
**at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional]
**at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional]
**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name |
**vendor** | Option<**String**> | | [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)

Expand Down
2 changes: 1 addition & 1 deletion samples/client/others/rust/hyper/oneOf/docs/Pizza.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**pizza_size** | Option<**f64**> | | [optional]
**href** | Option<**String**> | Hyperlink reference | [optional]
**id** | Option<**String**> | unique identifier | [optional]
**at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional]
**at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional]
**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name |
**pizza_size** | Option<**f64**> | | [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)

Expand Down
4 changes: 2 additions & 2 deletions samples/client/others/rust/hyper/oneOf/docs/PizzaSpeziale.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**toppings** | Option<**String**> | | [optional]
**pizza_size** | Option<**f64**> | | [optional]
**href** | Option<**String**> | Hyperlink reference | [optional]
**id** | Option<**String**> | unique identifier | [optional]
**at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional]
**at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional]
**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name |
**pizza_size** | Option<**f64**> | | [optional]
**toppings** | Option<**String**> | | [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)

Expand Down
24 changes: 12 additions & 12 deletions samples/client/others/rust/hyper/oneOf/src/models/bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,11 @@ use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Bar {
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "barPropA", skip_serializing_if = "Option::is_none")]
pub bar_prop_a: Option<String>,
#[serde(rename = "fooPropB", skip_serializing_if = "Option::is_none")]
pub foo_prop_b: Option<String>,
#[serde(rename = "foo", skip_serializing_if = "Option::is_none")]
pub foo: Option<Box<models::FooRefOrValue>>,
/// Hyperlink reference
#[serde(rename = "href", skip_serializing_if = "Option::is_none")]
pub href: Option<String>,
#[serde(rename = "id")]
pub id: String,
/// A URI to a JSON-Schema file that defines additional attributes and relationships
#[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")]
pub at_schema_location: Option<String>,
Expand All @@ -33,19 +27,25 @@ pub struct Bar {
/// When sub-classing, this defines the sub-class Extensible name
#[serde(rename = "@type")]
pub at_type: String,
#[serde(rename = "barPropA", skip_serializing_if = "Option::is_none")]
pub bar_prop_a: Option<String>,
#[serde(rename = "fooPropB", skip_serializing_if = "Option::is_none")]
pub foo_prop_b: Option<String>,
#[serde(rename = "foo", skip_serializing_if = "Option::is_none")]
pub foo: Option<Box<models::FooRefOrValue>>,
}

impl Bar {
pub fn new(id: String, at_type: String) -> Bar {
Bar {
id,
bar_prop_a: None,
foo_prop_b: None,
foo: None,
href: None,
id,
at_schema_location: None,
at_base_type: None,
at_type,
bar_prop_a: None,
foo_prop_b: None,
foo: None,
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions samples/client/others/rust/hyper/oneOf/src/models/bar_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct BarCreate {
#[serde(rename = "barPropA", skip_serializing_if = "Option::is_none")]
pub bar_prop_a: Option<String>,
#[serde(rename = "fooPropB", skip_serializing_if = "Option::is_none")]
pub foo_prop_b: Option<String>,
#[serde(rename = "foo", skip_serializing_if = "Option::is_none")]
pub foo: Option<Box<models::FooRefOrValue>>,
/// Hyperlink reference
#[serde(rename = "href", skip_serializing_if = "Option::is_none")]
pub href: Option<String>,
Expand All @@ -34,19 +28,25 @@ pub struct BarCreate {
/// When sub-classing, this defines the sub-class Extensible name
#[serde(rename = "@type")]
pub at_type: String,
#[serde(rename = "barPropA", skip_serializing_if = "Option::is_none")]
pub bar_prop_a: Option<String>,
#[serde(rename = "fooPropB", skip_serializing_if = "Option::is_none")]
pub foo_prop_b: Option<String>,
#[serde(rename = "foo", skip_serializing_if = "Option::is_none")]
pub foo: Option<Box<models::FooRefOrValue>>,
}

impl BarCreate {
pub fn new(at_type: String) -> BarCreate {
BarCreate {
bar_prop_a: None,
foo_prop_b: None,
foo: None,
href: None,
id: None,
at_schema_location: None,
at_base_type: None,
at_type,
bar_prop_a: None,
foo_prop_b: None,
foo: None,
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions samples/client/others/rust/hyper/oneOf/src/models/bar_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct BarRef {
/// Name of the related entity.
#[serde(rename = "name", skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
/// The actual type of the target instance when needed for disambiguation.
#[serde(rename = "@referredType", skip_serializing_if = "Option::is_none")]
pub at_referred_type: Option<String>,
/// Hyperlink reference
#[serde(rename = "href", skip_serializing_if = "Option::is_none")]
pub href: Option<String>,
Expand All @@ -34,18 +28,24 @@ pub struct BarRef {
/// When sub-classing, this defines the sub-class Extensible name
#[serde(rename = "@type")]
pub at_type: String,
/// Name of the related entity.
#[serde(rename = "name", skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
/// The actual type of the target instance when needed for disambiguation.
#[serde(rename = "@referredType", skip_serializing_if = "Option::is_none")]
pub at_referred_type: Option<String>,
}

impl BarRef {
pub fn new(at_type: String) -> BarRef {
BarRef {
name: None,
at_referred_type: None,
href: None,
id: None,
at_schema_location: None,
at_base_type: None,
at_type,
name: None,
at_referred_type: None,
}
}
}
Expand Down
23 changes: 11 additions & 12 deletions samples/client/others/rust/hyper/oneOf/src/models/entity_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,11 @@
use crate::models;
use serde::{Deserialize, Serialize};

/// EntityRef : Entity reference schema to be use for all entityRef class.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "@type")]
pub enum EntityRef {
#[serde(rename="BarRef")]
BarRef {
/// Name of the related entity.
#[serde(rename = "name", skip_serializing_if = "Option::is_none")]
name: Option<String>,
/// The actual type of the target instance when needed for disambiguation.
#[serde(rename = "@referredType", skip_serializing_if = "Option::is_none")]
at_referred_type: Option<String>,
/// Hyperlink reference
#[serde(rename = "href", skip_serializing_if = "Option::is_none")]
href: Option<String>,
Expand All @@ -35,15 +28,15 @@ pub enum EntityRef {
/// When sub-classing, this defines the super-class
#[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")]
at_base_type: Option<String>,
},
#[serde(rename="FooRef")]
FooRef {
/// Name of the related entity.
#[serde(rename = "name", skip_serializing_if = "Option::is_none")]
name: Option<String>,
/// The actual type of the target instance when needed for disambiguation.
#[serde(rename = "@referredType", skip_serializing_if = "Option::is_none")]
at_referred_type: Option<String>,
},
#[serde(rename="FooRef")]
FooRef {
/// Hyperlink reference
#[serde(rename = "href", skip_serializing_if = "Option::is_none")]
href: Option<String>,
Expand All @@ -56,18 +49,24 @@ pub enum EntityRef {
/// When sub-classing, this defines the super-class
#[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")]
at_base_type: Option<String>,
/// Name of the related entity.
#[serde(rename = "name", skip_serializing_if = "Option::is_none")]
name: Option<String>,
/// The actual type of the target instance when needed for disambiguation.
#[serde(rename = "@referredType", skip_serializing_if = "Option::is_none")]
at_referred_type: Option<String>,
},
}

impl Default for EntityRef {
fn default() -> Self {
Self::BarRef {
name: Default::default(),
at_referred_type: Default::default(),
href: Default::default(),
id: Default::default(),
at_schema_location: Default::default(),
at_base_type: Default::default(),
name: Default::default(),
at_referred_type: Default::default(),
}

}
Expand Down
12 changes: 6 additions & 6 deletions samples/client/others/rust/hyper/oneOf/src/models/foo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Foo {
#[serde(rename = "fooPropA", skip_serializing_if = "Option::is_none")]
pub foo_prop_a: Option<String>,
#[serde(rename = "fooPropB", skip_serializing_if = "Option::is_none")]
pub foo_prop_b: Option<String>,
/// Hyperlink reference
#[serde(rename = "href", skip_serializing_if = "Option::is_none")]
pub href: Option<String>,
Expand All @@ -32,18 +28,22 @@ pub struct Foo {
/// When sub-classing, this defines the sub-class Extensible name
#[serde(rename = "@type")]
pub at_type: String,
#[serde(rename = "fooPropA", skip_serializing_if = "Option::is_none")]
pub foo_prop_a: Option<String>,
#[serde(rename = "fooPropB", skip_serializing_if = "Option::is_none")]
pub foo_prop_b: Option<String>,
}

impl Foo {
pub fn new(at_type: String) -> Foo {
Foo {
foo_prop_a: None,
foo_prop_b: None,
href: None,
id: None,
at_schema_location: None,
at_base_type: None,
at_type,
foo_prop_a: None,
foo_prop_b: None,
}
}
}
Expand Down
Loading
Loading