Skip to content

Missing properties referencing other models in generated schema definition (-jaxrs2 2.0.3) #2915

@jsikkes

Description

@jsikkes

L.S.

We are experiencing the issue of missing properties and/or non existing properties when referencing child models ($ref) in the schema information of openapi.yaml. The generated yaml does not reflect the actual java Pojo structure.

Relevant Libraries:
'org.glassfish.jersey.containers', name: 'jersey-container-grizzly2-servlet', version: '2.27'
'org.glassfish.jersey.containers', name: 'jersey-container-grizzly2-http', version: '2.27'
'org.glassfish.jersey.inject', name: 'jersey-cdi2-se', version: '2.27'
'com.fasterxml.jackson.jaxrs', name: 'jackson-jaxrs-json-provider', version: '2.9.5'
'io.swagger.core.v3', name: 'swagger-jaxrs2', version: '2.0.3'
'io.swagger.core.v3', name: 'swagger-annotations', version: '2.0.3'

NutritionValueDTO.class

@Schema(name = "NutritionValue", description = "Nutritional value specification")
public class NutritionValueDTO implements Serializable {
    private final static long serialVersionUID = 1L;
    private String name;
    private QuantitativeValueDTO perServing;
    private QuantitativeValueDTO per100Gram;

    // Getters + Setters omitted 
}

QuantitativeValue.class

@Schema(name = "QuantitativeValue", description = "A combination of a value and associated unit")
public class QuantitativeValueDTO implements Serializable {

    private final static long serialVersionUID = 1L;

    @NotNull
    private double value;

    private String unitText;
    private String unitCode;

    // Getters + Setters omitted 
}

Current output:

components:
  schemas:
    QuantitativeValue:
      required:
      - value
      type: object
      properties:
        value:
          type: number
          format: double
        unitText:
          type: string
        unitCode:
          type: string
      description: A combination of a value and associated unit
    NutritionValue:
      type: object
      properties:
        name:
          type: string
        QuantitativeValue:
          $ref: '#/components/schemas/QuantitativeValue'
      description: Nutritional value specification

Expected output:

components:
  schemas:
    QuantitativeValue:
      required:
      - value
      type: object
      properties:
        value:
          type: number
          format: double
        unitText:
          type: string
        unitCode:
          type: string
      description: A combination of a value and associated unit
    NutritionValue:
      type: object
      properties:
        name:
          type: string
        perServing:
          $ref: '#/components/schemas/QuantitativeValue'
        per100Gram:
          $ref: '#/components/schemas/QuantitativeValue'
      description: Nutritional value specification

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions