Skip to content

Fix for [BUG] jaxrs-spec [server] oneOf, anyOf Polymorphism does not work#7789

Open
R1tschY wants to merge 8 commits intoOpenAPITools:masterfrom
R1tschY:jaxrsOneOf2
Open

Fix for [BUG] jaxrs-spec [server] oneOf, anyOf Polymorphism does not work#7789
R1tschY wants to merge 8 commits intoOpenAPITools:masterfrom
R1tschY:jaxrsOneOf2

Conversation

@R1tschY
Copy link

@R1tschY R1tschY commented Oct 22, 2020

Current rebase of #6253:

For the issue #5565 this is a fix in the current master 5.0.0-SNAPSHOT.
With this it is possible to generate oneOf interfaces and there related pojos in the jaxrs-spec codegen module

@bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10) @bkabrda (2020/01)

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • If contributing template-only or documentation-only changes which will change sample output, build the project beforehand.
  • Run the shell script ./bin/generate-samples.shto update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

@ifmolina
Copy link

Is this pull request going to be merged? I'm having the same issue with oneOf and anyOf :(

@seybi87
Copy link

seybi87 commented Nov 2, 2020

Same here, would be great to have this merge in the next release 👍 . @R1tschY thanks a lot for addressing this issue!

@tuxBurner
Copy link

Yes please merge it.
I did the work in #6253 and i am using it since in production and it works.

Thanks @R1tschY for rebasing it 👍

@seybi87
Copy link

seybi87 commented Nov 16, 2020

Yes please merge it.
I did the work in #6253 and i am using it since in production and it works.

Thanks @R1tschY for rebasing it 👍

@tuxBurner thanks a lot for addressing the issue.

I have built the openapi-codgen from your referenced branch https://github.com/micromata/openapi-generator/tree/fix/%235565 in #6253 for the jaxrs-jersey server and the java client with the following definition:

openapi: 3.0.0
info:
  version: 0.0.1
  title: OneOf example
  description: ''


paths:
 /animal:
    post:
      summary: Create a new animal   
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Animal'
              
      responses:
        '201':

components:
  schemas:
  
    Animal:
      type: object
      properties:
        name: 
          type: string
        props:  
          oneOf:
            - $ref: '#/components/schemas/Fish'
            - $ref: '#/components/schemas/Dog'
          discriminator:
              propertyName: animalType  
      
      
    Fish:
      type: object
      properties:
        animalType:
          type: string
        depth:
          type: integer
      required:
          - depth 
          - animalType   
      additionalProperties: false    

          
    
    Dog:
      type: object
      properties:
        animalType:
          type: string
        country:
          type: string   
      required:
          - country   
          - animalType
      additionalProperties: false        

Unfortunately, I am still facing the following compilation issue related to the oneOf keyword :

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project openapi-jaxrs-server: Compilation failure: Compilation failure:
[ERROR] /polymorphism-test/jax-rs-server/src/gen/java/org/openapitools/model/Animal.java:[21,30] cannot find symbol
[ERROR]   symbol:   class OneOfFishDog
[ERROR]   location: package org.openapitools.model
[ERROR] /polymorphism-test/jax-rs-server/src/gen/java/org/openapitools/model/Animal.java:[41,11] cannot find symbol
[ERROR]   symbol:   class OneOfFishDog
[ERROR]   location: class org.openapitools.model.Animal
[ERROR] /polymorphism-test/jax-rs-server/src/gen/java/org/openapitools/model/Animal.java:[63,23] cannot find symbol
[ERROR]   symbol:   class OneOfFishDog
[ERROR]   location: class org.openapitools.model.Animal
[ERROR] /polymorphism-test/jax-rs-server/src/gen/java/org/openapitools/model/Animal.java:[75,10] cannot find symbol
[ERROR]   symbol:   class OneOfFishDog
[ERROR]   location: class org.openapitools.model.Animal
[ERROR] /polymorphism-test/jax-rs-server/src/gen/java/org/openapitools/model/Animal.java:[79,24] cannot find symbol
[ERROR]   symbol:   class OneOfFishDog
[ERROR]   location: class org.openapitools.model.Animal

Any suggestions?

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

Successfully merging this pull request may close these issues.

4 participants