OpenAPITools / OpenAPITools/openapi-generator
[BUG] Description - generated code is giving lint errors
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Generated code is not lint safe, the below yaml (multipart file attachment), generates code like:
**os.File is reported as a 'gofmt' linting error
type ApiV7ValidatePostRequest struct {
ctx context.Context
ApiService *UserJourneyApiService
journey **os.File
}
ALSO, in the execute function, lint reports it as 'errcheck' linting error (returned error is not checked)
fbs, _ := ioutil.ReadAll(journeyLocalVarFile)
openapi-generator version
Manifest-Version: 1.0
mode: development
package: org.openapitools
implementation-version: 5.4.0
Build-Jdk-Spec: 1.8
Created-By: Maven Jar Plugin 3.2.0
url: https://github.com/openapitools/openapi-generator/modules/openapi
-generator-cli
Main-Class: org.openapitools.codegen.OpenAPIGenerator
OpenAPI declaration file content or url
post:
tags:
- User Journey
description: xxx
requestBody:
content:
multipart/form-data:
schema:
properties:
journey:
type: string
description: file name
format: binary
responses:
"200":
$ref: ErrorResponse.yaml
"401":
$ref: Unauthorised.yaml
Generation Details
java -jar ../../openapi/openapi-generator-cli.jar generate
-i api/XX.yaml
-g go
--additional-properties useOneOfDiscriminatorLookup=true,isGoSubmodule=false,sourceFolder=.,packageName=models
-o ./$1/models
--generate-alias-as-model
--git-user-id pol=xx
--git-repo-id xx
Steps to reproduce
Generate code using above
Related issues/PRs
Suggest a fix
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository files or tests are named. Start by running the provided OpenAPI Generator command with the multipart/form-data YAML, then inspect the generated Go request struct and execute function shown in the report. Done means the generated code no longer produces the reported gofmt and errcheck lint errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, java, openapi
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100