Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #8483
Closed
Open
Issue created Jan 20, 2021 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG] [Go] Execution responses and errors are values not pointers

Created by: aeneasr

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

Generating a Go-client yields in code that does not adhere to Golang's error handling. Request executors return GenericOpenAPIError as a value:

func (r AdminApiApiDeleteIdentityRequest) Execute() (*_nethttp.Response, GenericOpenAPIError) {
	return r.ApiService.DeleteIdentityExecute(r)
}

which makes it impossible to check if err != nil as the variable is a value (and thus always not nil) and not a pointer. Instead, this should read:

func (r AdminApiApiDeleteIdentityRequest) Execute() (*_nethttp.Response, *GenericOpenAPIError) {
	return r.ApiService.DeleteIdentityExecute(r)
}

The same applies to return values which should also be pointers, not structs:

func (a *HealthApiService) IsInstanceReadyExecute(r HealthApiApiIsInstanceReadyRequest) (HealthStatus, *_nethttp.Response, GenericOpenAPIError) {

should be:

func (a *HealthApiService) IsInstanceReadyExecute(r *HealthApiApiIsInstanceReadyRequest) (HealthStatus, *_nethttp.Response, *GenericOpenAPIError) {
openapi-generator version

5.0.0

OpenAPI declaration file content or url

https://gist.github.com/aeneasr/3c11c5b454df6c5e4d8e7a3e16d04db7

Generation Details
# gen.go.yml
disallowAdditionalPropertiesIfNotPresent: false
packageName: kratos
generateInterfaces: false
isGoSubmodule: false
structPrefix: true
$ npm run openapi-generator-cli -- generate -i ".schema/api.openapi.json" \
				-g go \
				-o "internal/httpclient" \
				--git-user-id ory \
				--git-repo-id kratos-client-go \
				--git-host github.com \
				-c .schema/openapi/gen.go.yml
Steps to reproduce

See above.

Related issues/PRs
Suggest a fix

I know too little java and internals of how this system works. But basically calls to GenericOpenAPIError{/* ... */} should always be pointers &GenericOpenAPIError{ /* ... */ }. Same for API return values.

Assignee
Assign to
Time tracking