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

[Golang][client] undefined optional error in generated go code #1082

Open
anandshah05 opened this issue Sep 22, 2018 · 1 comment
Open

[Golang][client] undefined optional error in generated go code #1082

anandshah05 opened this issue Sep 22, 2018 · 1 comment

Comments

@anandshah05
Copy link
Contributor

anandshah05 commented Sep 22, 2018

Description

The generated go code for the yaml file, contains optional struck but missing optional import statement

openapi-generator version

3.2.0
same issue on master

OpenAPI declaration file content or url

auth.yaml

openapi: 3.0.0
info:
  version: 1.0
  title: AUTH API
paths:
  /ue-authentications/{authCtxId}/eap-session:
    post:
      operationId: EapAkaPrime
      parameters:
        - name: authCtxId
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EapSession'
      responses:
        '200':
          description: Use to handle or close the EAP session
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EapSession'
            application/3gppHal+json:
              schema:
                type: object
                properties:
                  eapPayload:
                    $ref: '#/components/schemas/EapPayload'
                required:
                  - eapPayload
                  - _links
components:
  schemas:
    EapSession:
      type: object
      properties:
        eapPayload:
          $ref: '#/components/schemas/EapPayload'
        kSeaf:
          $ref: '#/components/schemas/Kseaf'
      required:
        - eapPayload
    AuthResult:
      type: string
      enum:
        - AUTHENTICATION_SUCCESS
        - AUTHENTICATION_FAILURE
        - AUTHENTICATION_ONGOING
    EapPayload:
      type: string
      format: base64
      description: contains an EAP packet
    Kseaf:
      type: string
      pattern: '[A-Fa-f0-9]{64}'
    ResStar:
      type: string
      pattern: '[A-Fa-f0-9]{32}'
    HxresStar:
      type: string
      pattern: '[A-Fa-f0-9]{32}'
    AuthType:
      type: string
      enum:
        - 5G_AKA
        - EAP_AKA_PRIME

Command line used for generation
generate -g go -i auth.yaml -o generated/go
Steps to reproduce

Generated code using above yaml and it will generate go code with import missing

Suggest a fix/enhancement

In AbstractGoCodegen.java - it seems, import is added only for primitives

  • // import "optionals" package if the parameter is primitive and optional
  • if (!param.required && param.isPrimitiveType) {
  • // import "optionals" package if the parameter is optional
  • if (!param.required) {
@axl89
Copy link

axl89 commented Aug 14, 2020

I faced this same issues with the latest 3.X version.

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

No branches or pull requests

3 participants