OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.84k stars 6.59k forks source link

[BUG][Go][Client] Invalid syntax for nullable binary #18006

Open dtrunk90 opened 8 months ago

dtrunk90 commented 8 months ago

Bug Report Checklist

Description

The generated code has invalid syntax and produces the following error: syntax error: unexpected * in struct type; possibly missing semicolon or newline or }

openapi-generator version

7.3.0

OpenAPI declaration file content or url
    content:
      type: string
      format: binary
      nullable: true

Spec from https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/api-reference/v2.0/dynamics-open-api#download-business-central-openapi-specification

Generates following go struct field:

Content Nullable*os.File `json:"content,omitempty"`
Generation Details

openapi-generator-cli generate -c config.yaml --skip-operation-example

generatorName: go
inputSpec: bcoas1.0.yaml
outputDir: ./lib
packageName: businesscentral
withGoMod: false
Steps to reproduce

Try to use and compile the code. It will fail.

Related issues/PRs
Suggest a fix
TobiPeterG commented 4 months ago

I have the same issue, has a solution/workaround been found?

dtrunk90 commented 4 months ago

I have the same issue, has a solution/workaround been found?

We switched to use the swaggerapi/swagger-codegen-cli-v3 docker image to generate the code.

TobiPeterG commented 2 months ago

We solved it by patching our openapi spec to remove the nullable property where they create issues.

dtrunk90 commented 2 months ago

We solved it by patching our openapi spec to remove the nullable property where they create issues.

That's not an option for us because the spec is a contract between server and client which shouldn't be changed client side.