openapi-generator: [BUG] ERROR! Not handling as Body Parameter at the moment

Description

I get the following error when trying to generate a Go client:

[main] ERROR o.o.codegen.DefaultCodegen - ERROR! Not handling  class Parameter {
    name: null
    in: null
    description: null
    required: null
    deprecated: null
    allowEmptyValue: null
    style: null
    explode: null
    allowReserved: null
    schema: null
    examples: null
    example: null
    content: null
    $ref: #/components/parameters/idempotencyKey
} as Body Parameter at the moment

This comes about when my root.yaml file contains a paths sub-object with a $ref to an external OpenAPI spec file for a path like:

paths:
  /originators:
    post:
      tags:
        - Originators
      summary: Create a new Originator object
      operationId: addOriginator
      security:
        - bearerAuth: []
        - cookieAuth: []
      parameters:
        - $ref: '#/components/parameters/requestId'
        - $ref: '#/components/parameters/idempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateOriginator'        

  parameters:
    idempotencyKey:
      in: header
      name: X-Idempotency-Key
      description: Idempotent key in the header which expires after 24 hours. These strings should contain enough entropy for to not collide with each other in your requests.
      example: a4f88150
      required: false
      schema:
        type: string
openapi-generator version

4.0.0-beta2

Steps to reproduce
OPENAPI_GENERATOR_VERSION=4.0.0-beta2 ./openapi-generator generate -i openapi.yaml -g go -o ./client
Suggest a fix

Looking at the relevant source code this path is simply commented out (and has been for quite some time), so I assume there’s a refactor needed?

I’m willing to offer a patch which fixes this, but I’m unsure of the history or what all would need to be refactored. Any advice? I’ll contribute a reproducible local test as part of the PR.

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 1
  • Comments: 20 (4 by maintainers)

Most upvoted comments

I had the same issue and am running exactly the same command as @danielbartsch

I validated my schema against https://editor.swagger.io/ and fixed errors it had shown (was missing schema for params in my case).

Fix those and you’ll be fine.

openapi-generator-cli validate did not catch those.