It is not possible to create Schema with array of referenced items
See original GitHub issueVersions: 1.0.1, 1.1.2, 2.0-MR1
I’m using the following annotation for schema:
@Schema(required = true, description = "Some description...", type = SchemaType.ARRAY, ref = "name1")
What I’m getting is:
variableName:
$ref: '#/components/schemas/name1'
What I expect to get:
variableName:
type: array
description: Some description...
items:
$ref: '#/components/schemas/name1'
It looks like ref is overriding all of data in @Schema object. I have tried a lot of modifications for mentioned annotation, but only pseudo-success is when I have add an ‘implementation’ element pointing to class- but that’s not satisfying solution. I’m sorry for not pasting original content, but it’s protected by contract.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:8 (6 by maintainers)
Top Results From Across the Web
How do you create a swagger schema that includes an array ...
In OpenAPI 2.0, you can define an object with varying properties as just type: object (free-form object). For your case, you may want...
Read more >I have an array of references to a country schema type but it ...
I have an array of references to a country schema type, does this query look like it should work? It always just returns...
Read more >mongoose: Referencing schema in properties or arrays
When using a NoSQL database like MongoDb, most of the time you'll have documents that contain all properties by itself.
Read more >array — Understanding JSON Schema 2020-12 documentation
While the items schema must be valid for every item in the array, the contains schema only needs to validate against one or...
Read more >Mongoose v6.8.0: SchemaTypes
ObjectId SchemaType doesn't actually create MongoDB ObjectIds, ... You can declare a schema type using the type directly, or an object with a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes that is the contract for the
ref
property. That property is mutually exclusive with all other properties on@Schema
.@KrystianRos, @0xqab - I would suggest you try either
(1) implementing an
OASModelReader
and having it produce the correct arraySchema
incomponents
which can then be referenced by name usingref
in@Schema
annotations throughout your code or (2) Specify the same schema in components in a static YAML or JSON file which can also be referenced withref
.@0xqab mentioned the use of Payara, which implementation are you using @KrystianRos ? I expect the type = ARRAY with
implementation = MyClass.class
to work with runtimes using SmallRye.