OpenAPITools / OpenAPITools/openapi-generator

[BUG][go-server] Invalid indirect of os.File

Open
#13,206 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

Writing a spec for POSTing a file generates a post endpoint with a compiler error:

func (c *VaultApiController) VaultPost(w http.ResponseWriter, r *http.Request) {
	bodyParam := *os.File{}

invalid indirect of os.File

openapi-generator version

6.0.1

OpenAPI declaration file content or url

Endpoint definition:

/vault:
  post:
    tags:
      - Vault
    requestBody:
      content:
        application/pdf:
          schema:
            type: string
            format: binary
Generation Details
openapitools/openapi-generator-cli:v6.0.1 generate \
  -i "[...]" \
  -g go-server -o /output \
  --package-name genapi \
  --model-package genapi \
  --additional-properties=router=chi,addResponseHeaders=true
Steps to reproduce

See above

Related issues/PRs
Suggest a fix

Change the *os.File{} dereference call to an &os.File{} pointer

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

Reproduce the issue with the provided OpenAPI requestBody and the v6.0.1 go-server generation command. Trace the go-server templates or generator entry points that render binary file request bodies, then compile the generated endpoint to verify the invalid indirect is gone and the resulting pointer initialization is valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, java
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.