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

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

Closed
jsikkes opened this issue Aug 15, 2018 · 1 comment

Comments

@jsikkes
Copy link

jsikkes commented Aug 15, 2018

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
frantuma added a commit that referenced this issue Aug 18, 2018
frantuma added a commit that referenced this issue Aug 18, 2018
@frantuma
Copy link
Member

Hey @jsikkes, thanks for reporting this! it's indeed a bug, fixed in #2917 and available in latest 2.0.4-SNAPSHOT on sonatype. Please reopen the ticket if you're still experiencing issues.

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