Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed template rendering with current version of go-swagger #40

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jpriebe
Copy link

@jpriebe jpriebe commented Nov 20, 2020

Recently I started getting these errors when I try to compile code generated with stratoscale/swagger:

restapi/operations/foo/foo_create_parameters.go:56:38: not enough arguments in call to "github.com/go-openapi/errors".Required
        have (string, string)
        want (string, string, interface {})

A breaking change was made to go-openapi/errors in the summer of 2020:

In order for go-swagger-generated code to compile properly, you need to use at least version v0.24.0 of go-swagger:

Unfortunately, stratoscale/swagger is not compatible with the latest versions of go-swagger; the template fails to render with this error:

failed rendering template data for configure: template execution failed for template configure: template: serverConfigureapi:142:149: executing "serverConfigureapi" at <.WithContext>: can't evaluate field WithContext in type generator.GenOperation

I fixed this by removing the {{ if .WithContext }} conditional from the Operations block in server/configureapi.gotmpl. The template renders and the resulting code is compatible with the latest go-openapi/errors.

I'm not clear on the implications of removing the WithContext conditional. It's possible that other changes need to be made to the templates to compensate for the removal of this block. I'll leave that up to the experts. But I'd greatly appreciate a 1.0.28 release with a fix for this incompatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant