Skip to content
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

ArraySchema annotation items() value does not appear to be properly supported #4610

Closed
pjfanning opened this issue Feb 2, 2024 · 1 comment
Assignees

Comments

@pjfanning
Copy link
Contributor

I may or may not be correct but the ArraySchema annotation now has items() and schema() but they both have the same Javadoc. I assume that items() is meant to be a synonym for schema() but is less ambiguously named. items() is a recent addition.

See https://docs.swagger.io/swagger-core/v2.2.20/apidocs/io/swagger/v3/oas/annotations/media/ArraySchema.html

I have a test case in Scala where I use an ArraySchema annotation to override the item implementation. I have 2 variants. One that uses schema and the other that uses items but the override only works with schema.

I'm using swagger 2.2.20.

The 2 classes are in:
https://github.com/swagger-akka-http/swagger-scala-module/blob/develop/src/test/scala/models/AddRequest.scala

The AddRequestOldStyleAnnotation variant works as expected when I run it through the swagger-core ModelResolver.

I suspect that this line is at fault

((io.swagger.v3.oas.annotations.media.ArraySchema) resolvedSchemaOrArrayAnnotation).schema() :

Note how it only looks at the schema value and not the items value.

@frantuma
Copy link
Member

frantuma commented Feb 5, 2024

Thanks for reporting this. It looks like a bug introduced while implementing support for OpenAPI 3.1, as ArraySchema.schema already represents the schema of the items in the array, and ArraySchema.items is a duplicate that has been only processed in terms of types and only in case of OpenAPI 3.1.

#4611 deprecates ArraySchema.items for future removal, adding support for OAS 3.1 types by processing existing schema field.

@frantuma frantuma closed this as completed Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants