swagger-api / swagger-parser

Swagger Spec to Java POJOs
http://swagger.io
Apache License 2.0
780 stars 526 forks source link

[Composite types] When allOf contains only one type don't generate union classes #2054

Open SergioArrighi opened 7 months ago

SergioArrighi commented 7 months ago

Hello all,

I don't know if this may be of interest, but I think I saw some issues logged here and there of people asking for this kind of behaviour. I originally wanted to make it optional, but I did't find any way to have some kind of configuration.

Thanks for the awesome work everybody and best regards.

gracekarina commented 7 months ago

Hi @SergioArrighi, this change breaks many tests, this could be added as an option if you follow the logic of the resolveCombinators option. thanks

Failures: Error: OpenAPIResolverTest.componentsResolver:417 ClassCast class io.swagger.v3.oas.models.media.ObjectSchema cannot be cast to class io.swagger.v3.oas.models.media.ComposedSchema (io.swagger.v3.oas.models.media.ObjectSchema and io.swagger.v3.oas.models.media.ComposedSchema are in unnamed module of loader 'app') Error: OpenAPIResolverTest.testComposedSchemaAdjacent:1012 NullPointer Error: OpenAPIV3ParserTest.testComposedSchemaAdjacent:1396 NullPointer Error: OpenAPIV3ParserTest.testIssue1777:128 expected [The id of the customer] but found [null] Error: OpenAPIV3ParserTest.testIssue1802:143 expected object to not be null Error: OpenAPIV3ParserTest.testIssueDereferencingComposedSchemaOneOf:84 expected object to not be null Error: OpenAPIV3ParserTest.testOneOfExternalRefConflictName:1405 NullPointer Error: OpenAPIDeserializerTest.testIssue1454AllOfDefaultValue:2892 expected [SCHEMA_DEFAULT] but found [null]

SergioArrighi commented 7 months ago

Hello @gracekarina , thanks for the time you took to review this PR. Yes I first wanted to understand if it would be interesting for the project to have this kind of possibility and also to get some guidance on how to have a feature toggle for it. I will look into "resolveCombinators" as soon as I will have some time. Thanks again for the review and for your work. Regards