OpenAPITools / OpenAPITools/openapi-generator

[BUG] ERROR! Not handling <code> as Body Parameter at the moment

Open
#2,580 22 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: Go Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java at the referenced parameter-handling path, then reproduce the failure with the supplied openapi-generator command and YAML. Add the mentioned local regression test and verify that Go client generation completes without the “Not handling ... as Body Parameter” error.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, java, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.