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

[BUG][JAVA] Regression on Java webclient generation with 7.9.0 #20459

Closed
3 of 6 tasks
nvervelle opened this issue Jan 13, 2025 · 6 comments · Fixed by #20461
Closed
3 of 6 tasks

[BUG][JAVA] Regression on Java webclient generation with 7.9.0 #20459

nvervelle opened this issue Jan 13, 2025 · 6 comments · Fixed by #20461

Comments

@nvervelle
Copy link
Contributor

nvervelle commented Jan 13, 2025

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

See first slack thread and second slack thread

When trying to upgrade from openapi-generator 7.8.0 to 7.9.0, I end up with a result that doesn't compile for one specification :

  • I'm using Java webclient generation
  • The generated api.xxxApi classes include an import of dto.OneOf, but there's no dto package and no OneOf class/interface generated
  • The openapi specification I'm using is adapted from this one (removed a few things we don't need, cleaned...). I'm attaching the actual specification I'm using.

The only place where I see oneOf in the openapi specification is for errors with references to components that have just a description.

With 7.8.0 :

  • The import is for a correctly named DTO dto.ApiSecureEnvironmentNameGetKeyGet403Response
  • The DTO is actually generated in the dto package

Is this a new bug?
Can it be a side effect of #19781 or #19758 ?

openapi-generator version

It's failing with version 7.9.0, but was working with 7.8.0

OpenAPI declaration file content or url

Put on slack here

Generation Details
Steps to reproduce
Related issues/PRs

It may be a side effect of #19781 or #19758

Suggest a fix
@wing328
Copy link
Member

wing328 commented Jan 14, 2025

here is the spec for those who do not have a slack account:

openapi: 3.0.0

# INFO SECTION
info:
  title: ESP APIs
  version: 23.1.0
  description: "ESP APIs technical reference."
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html

# TAGS
tags:
  - name: Get Key
    description: Get key endpoint
    externalDocs:
      description: Get key Documentation
      url: https://namirialgroup.github.io/esp-docs/integrations/getkey
  - name: Get user
    description: Get user endpoint
    externalDocs:
      description: Get user Documentation
      url: https://namirialgroup.github.io/esp-docs/integrations/token

# PATHS
paths:
  # GET KEY
  /api/secure/{environment_name}/getKey:
    get:
      tags:
        -  Get Key
      summary: Get a authn key to start an authentication flow
      security:
        - ApiKeyAuth: [ ]
      parameters:
        - in: path
          name: environment_name
          schema:
            type: string
          required: true
        - in: header
          name: Esp-Api-Key
          schema:
            type: string
          required: true
        - in: query
          name: level
          schema:
            type: string
          required: true
          description: The authentication level. It should be refered to L1-L2-L3 (The L letter should be removed!)
          example: 1
        - in: query
          name: attributes
          schema:
            type: string
          required: true
          description: The attribute parameter (Base-Full)
          example: Full
        - in: query
          name: spidType
          schema:
            type: string
          required: false
          description: The SPID SAML Purpose value
          example: F - LP - PG - PF - PX
      responses:
        '200':
          description: The authn key
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/GetKeyResponse'
        '400':
          description: The input parameters are missing or invalid
        '403':
          description: Forbidden error
          content:
            text/plain:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/ApiKeyError'

  #Get User
  /api/secure/{environment_name}/getUser:
    get:
      tags:
        -  Get user
      summary: Get a user JWT
      security:
        - ApiKeyAuth: [ ]
      parameters:
        - in: path
          name: environment_name
          schema:
            type: string
          required: true
        - in: header
          name: Esp-Api-Key
          schema:
            type: string
          required: true
        - in: query
          name: ID
          schema:
            type: string
          required: true
          description: The ESP user identifier
          example: _ecf182c0024338b109397ea3d04ab141
        - in: query
          name: key
          schema:
            type: string
          required: true
          description: The ESP session key
          example: _029da15302d1f7bf8a4ff9826b4489c3
      responses:
        '200':
          description: The authn key
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/JWTBearerResponse'
        '400':
          description: missing key or ID parameter
        '403':
          description: Forbidden error
          content:
            text/plain:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/ApiKeyError'
                  - $ref: '#/components/schemas/KeyIdNotFound'


externalDocs:
  description: Official ESP documentation
  url: https://namirialgroup.github.io/esp-docs/
servers:
  - url: https://esp-saas.test.namirialtsp.com
    description: (Test Saas)
  - url: https://esp-saas.namirialtsp.com
    description: (Prod Saas)
components:
  securitySchemes:
    ApiKeyAuth:        # arbitrary name for the security scheme
      type: apiKey
      in: header       # can be "header", "query" or "cookie"
      name: Esp-Api-Key  # name of the header, query parameter or cookie
    sslCertificate: # arbitrary name for the security scheme
      type: http
      scheme: basic
  schemas:
    InvalidParameter:
      description: Invalid Request Parameter
    InvaidFinal:
      description: Error code 1 - Invalid final url
    InvalidLevel:
      description: Error code 2 - Invalid level parameter
    InvalidAttributes:
      description: Error code 3 - Invalid attributes parameter
    InvalidAuthnKey:
      description: Error code 4 - Invalid authn key
    AuthnKeyMismatch:
      description: Error code 5 - The authn key has a mismatch with the SP configuration
    MissingAuthnKey:
      description: Error code 6 - The authn key is missing
    GenericAuthError:
      description: Error code 7/8 - Generic authentication error
    RedirectUriMissing:
      description: Error code 9 - The SP redirect uri misses into the configuration
    UnderLevel:
      description: Error code 10 - The authentication level obtained from lower SPID to what is requested through authnKey
    LevelMismatch:
      description: Error code 11 - There is a level mismatch between requested level and authn key level
    CurrentSessionLevel:
      description: Error code 12 - The authentication level of a SPID session already active not corresponding to the currently requested level
    KeyIdNotFound:
      description: Error code 3 - The session is missing for input key and ID parameters
    SSLError:
      description: SSL authentication error
    ApiKeyError:
      description: ApiKey authentication error
    GetKeyResponse:
      type: string
      example: c1BUQkJ4d3hYUWV6ZEQ4TktlSWV6ZmozVy9HNzNrQlcyRFlvMTB1TTlGKzE3dWNjdHNLV2RUN0pVNTNJQnhsVnNMMWhBS0lucGNxMC9qY0c3U3BWYlc5dktOMXFvVkhyYUIrdDFBd1VBWGM5bERzS1RnVzd1V251R3pWUEpiUmc
    JWTBearerResponse:
      type: string
      description: jwt that contains the SAML Assertion attributes
    SessionIdKeyResponse:
      type: string
      description: querystring with session key and id

@wing328
Copy link
Member

wing328 commented Jan 14, 2025

as a workaround, please set the normalizer rule SIMPLIFY_ONEOF_ANYOF to false

e.g.

java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i /tmp/oneof.yaml -o /tmp/oneof2/ --openapi-normalizer SIMPLIFY_ONEOF_ANYOF=false

doc: https://github.com/openapitools/openapi-generator/blob/master/docs/customization.md#openapi-normalizer

@wing328
Copy link
Member

wing328 commented Jan 14, 2025

UPDATE: filed #20461 to fix the issue (any type handling in normalizer)

@nvervelle
Copy link
Contributor Author

Hi @wing328 ,

I confirm that setting the normalize rule SIMPLIYFY_ONEOF_ANYOF to false allows me to fix the problem.

Thank you very much !

@wing328
Copy link
Member

wing328 commented Jan 14, 2025

PR merged.

Please give the fix a try later with the latest master when you've time.

@nvervelle
Copy link
Contributor Author

Hi, can it wait until you have made a release ?

I ask because the openapi-generator is provided through dependencies that span through several projects, so I can't easily test master on the project that fails with 7.9.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants