question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

It is not possible to create Schema with array of referenced items

See original GitHub issue

Versions: 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:open
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
EricWittmanncommented, May 5, 2020

Yes that is the contract for the ref property. That property is mutually exclusive with all other properties on @Schema.

0reactions
MikeEdgarcommented, May 28, 2020

@KrystianRos, @0xqab - I would suggest you try either

(1) implementing an OASModelReader and having it produce the correct array Schema in components which can then be referenced by name using ref 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 with ref.

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found