Uploaded image for project: 'FlightPath'
  1. FlightPath
  2. FLPATH-346

Generation of `openapi.json` file skip some of the annotated properties

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Undefined Undefined
    • v1.0.11
    • None
    • parodos-backend
    • None
    • False
    • Hide

      None

      Show
      None
    • False

      The plugin springdoc-openapi-maven-plugin  generate `openapi.json` reading Java classes annotated with `@RequestMapping`.

      At the moment, it doesn't generate model class fields annotated with `@JsonInclude(JsonInclude.Include.NON_EMPTY`.

      This lead to generating SDK model classes with missing parameters.

      For example the `WorkRequestDTO`generated class  doesn't have the field `works` that is available in WorkRequestDTO

       Integration tests fail if a field is missing. For example:
      ```
      INFO com.redhat.parodos.flows.utils.IntegrationTestUtils - onFailure Message: java.lang.IllegalArgumentException: The field `works` in the JSON string is not defined in the `WorkStatusResponseDTO` properties. JSON: {"name":"subWorkFlowThree","type":"WORKFLOW","status":"IN_PROGRESS","works":[

      {"name":"sslCertificationWorkFlowTask","type":"TASK","status":"IN_PROGRESS"}

      ,{"name":"subWorkFlowTwo","type":"WORKFLOW","status":"IN_PROGRESS","works":[{"name":"subWorkFlowOne","type":"WORKFLOW","status":"COMPLETED","works":[

      {"name":"adGroupsWorkFlowTask","type":"TASK","status":"COMPLETED"}

      ,

      {"name":"splunkMonitoringWorkFlowTask","type":"TASK","status":"COMPLETED"}

      ]},

      {"name":"namespaceWorkFlowTask","type":"TASK","status":"IN_PROGRESS"}

      ]}]}
      ```

      Some debug info

      • if you substitute `@JsonInclude(JsonInclude.Include.NON_EMPTY` with `@JsonInclude(JsonInclude.Include.NON_NULL` and execute `mvn clean package`, then the `works` field will appear both in `WorkRequestDTO`generated class and in the `openapi.json` file.
      • Updrading jackson version to latest, improve the `openapi.json` but doesn't solve the issue.
      • add in `application.yml` the `spring.jackson.serialization-inclusion=non_empty` seems to not be effective (TO DOUBLE CHECK)

      There are several classes that use the `NON_EMPTY` annotation, here the list:
      ```
      workflow-service/src/main/java/com/redhat/parodos/project/dto/ProjectResponseDTO.java
      workflow-service/src/main/java/com/redhat/parodos/workflow/definition/dto/WorkDefinitionResponseDTO.java
      workflow-service/src/main/java/com/redhat/parodos/workflow/definition/dto/WorkDefinitionResponseDTO.java
      workflow-service/src/main/java/com/redhat/parodos/workflow/definition/dto/WorkFlowDefinitionResponseDTO.java
      workflow-service/src/main/java/com/redhat/parodos/workflow/definition/dto/WorkFlowDefinitionResponseDTO.java
      workflow-service/src/main/java/com/redhat/parodos/workflow/definition/dto/WorkFlowDefinitionResponseDTO.java
      workflow-service/src/main/java/com/redhat/parodos/workflow/definition/dto/WorkParameterValueRequestDTO.java
      workflow-service/src/main/java/com/redhat/parodos/workflow/execution/dto/WorkFlowContextResponseDTO.java
      workflow-service/src/main/java/com/redhat/parodos/workflow/execution/dto/WorkFlowOptionsResponseDTO.java
      workflow-service/src/main/java/com/redhat/parodos/workflow/execution/dto/WorkFlowResponseDTO.java
      workflow-service/src/main/java/com/redhat/parodos/workflow/execution/dto/WorkFlowResponseDTO.java
      workflow-service/src/main/java/com/redhat/parodos/workflow/execution/dto/WorkFlowStatusResponseDTO.java
      workflow-service/src/main/java/com/redhat/parodos/workflow/execution/dto/WorkStatusResponseDTO.java
      ```

            masayag@redhat.com Moti Asayag
            gciavarrini@redhat.com Gloria Ciavarrini
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: