Swagger-core: JSON wrapper object not mapped to proper OpenAPI model

Created on 20 Jul 2018  路  6Comments  路  Source: swagger-api/swagger-core

When a class is annotated with

@com.fasterxml.jackson.annotation.JsonTypeInfo(use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, include = com.fasterxml.jackson.annotation.JsonTypeInfo.As.WRAPPER_OBJECT)

it is being serialized as an object, rather than a simple string.
The OpenAPI model for such a class is represented as a simple value.

See example attached to issue #2862.

Serialized:

{"ExampleSubType":"VALUE1"}

Model:

Example:
  type: object
ExampleSubType:
  type: string
  allOf:
  - $ref: '#/components/schemas/Example'
  enum:
  - VALUE1
  - VALUE2

Most helpful comment

any progress on this issue?

All 6 comments

I need this too :(
@lwielek, have you found a workaround?

@jbraga
no, my workaround was not to use wrapper object annotations ...

any progress on this issue?

This is quite painful bug which blogs us to use specification generated from code. This test: https://github.com/swagger-api/swagger-core/blob/4f30e3eb594790bdbe4f4a12553a54e2f7d8c5cd/modules/swagger-core/src/test/java/io/swagger/v3/core/converting/ModelConverterTest.java#L130 is invalid.
It should be: employee.getProperties().get("employee").getProperties();

Is there anyone reading this, or has development on swagger stopped?

@dazraf there is indeed somebody reading, and nope, development has not stopped; as always contributions are more than welcome though..

That said a partial implementation has been implemented in #3921, available in latest snapshot and next release.

Was this page helpful?
0 / 5 - 0 ratings