Uploaded image for project: 'WildFly WIP'
  1. WildFly WIP
  2. WFWIP-693

MicroProfile OpenAPI and multiple deployments: RequestSchemaBody annotations carrying identical class names generate wrong OpenAPI documentation

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Blocker Blocker
    • MP OpenAPI
    • None
    • Hide

      1. Build the WildFly snapshot based on the feature branch:

      • git clone git@github.com:pferraro/wildfly.git
      • cd wildfly
      • git checkout openapi
      • mvn clean install -DskipTests

      2. Run the tests

      • git clone git@github.com:fabiobrz/eap-microprofile-test-suite.git
      • cd eap-microprofile-test-suite
      • git checkout issue-344.mp-openapi-multi-war
      • mvn clean verify -pl microprofile-open-api -am -Djboss.dist=<WILDFLY_SNAPSHOT_BUILD_DIRECTORY> -Dtest=MultipleLocalServiceRouterWarsAffectingGlobalPropertiesTest#testConflictingSchemaReferencesAreListedByComponents
      Show
      1. Build the WildFly snapshot based on the feature branch: git clone git@github.com:pferraro/wildfly.git cd wildfly git checkout openapi mvn clean install -DskipTests 2. Run the tests git clone git@github.com:fabiobrz/eap-microprofile-test-suite.git cd eap-microprofile-test-suite git checkout issue-344.mp-openapi-multi-war mvn clean verify -pl microprofile-open-api -am -Djboss.dist=<WILDFLY_SNAPSHOT_BUILD_DIRECTORY> -Dtest=MultipleLocalServiceRouterWarsAffectingGlobalPropertiesTest#testConflictingSchemaReferencesAreListedByComponents
    • User Experience

      • Have two different applications which define a MyPojo.class object, say in package1 and package2.
      • Both package1.MyPojo and package2.MyPojo expose an id field, but package2.MyPojo also exposes a name field.
      • Then have a deployment1.war, containing a PojoExampleResource class that exposes a printPojo API, which @Consumes(MediaType.APPLICATION_JSON) and declares a parameter of type package1.MyPojo, which is annotated as @RequestBodySchema(package1.MyPojo.class).
      • Finally, have a deployment2.war, containing a AnotherPojoExampleResource class that exposes a printAnotherPojo API, which @Consumes(MediaType.APPLICATION_JSON) and declares a parameter of type package2.MyPojo, which is annotated as @RequestBodySchema(package2.MyPojo.class).

      When deploying both the applications, specifically deployment1.war first, and then deployment2.war, the resulting OpenAPI document would contain:

      components:
        schemas:
          MyPojo:
            type: object
            properties:
              id:
                type: string
              name:
                type: string
      ...
      

      So package1.MyPojo is not documented.

      Additionally, the documented operations would refere to the only documented schema reference, i.e.

      ...
        /deployment2.war/another-example/another-pojo-example:
          get:
            requestBody:
              content:
                application/json:
                  schema:
                    $ref: "#/components/schemas/MyPojo"
            responses:
              "200":
                description: OK
      ...
        /deployment1.war/example/pojo-example:
          get:
            requestBody:
              content:
                application/json:
                  schema:
                    $ref: "#/components/schemas/MyPojo"
            responses:
              "200":
                description: OK
      

      A client which is generated based on such OpenAPI documentation would create wrong stubs for /deployment1.war/example/pojo-example , possibly causing unknown property errors in server side deserialization.

      This, along with WFWIP-694, seems to be due to a common set of conditions in the functional code which are the cause for everything which is generated by class level annotations and that is then reflected into the global components property of the generated OpenAPI documentation to be affected by overriding issues.

              pferraro@redhat.com Paul Ferraro
              fburzigo@redhat.com Fabio Burzigotti
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: