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

Why are response models private? #59

Closed
VadimKulagin opened this issue Sep 13, 2019 · 3 comments
Closed

Why are response models private? #59

VadimKulagin opened this issue Sep 13, 2019 · 3 comments

Comments

@VadimKulagin
Copy link

I want to use API response models from other packages, but for some reason they are now generated privately (their names begin with a small letter):

type getFirstPetResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *Pet
}

Why are they private?

@utx0
Copy link
Contributor

utx0 commented Oct 29, 2019

Can you provide the swagger spec you are using?

@MrWako
Copy link
Contributor

MrWako commented Mar 5, 2020

I've just hit this issue too. It can be seen in the petstore example client https://github.com/deepmap/oapi-codegen/blob/master/examples/petstore-expanded/petstore-client.gen.go with the FindPetsWithResponse:

func (c *ClientWithResponses) FindPetsWithResponse(ctx context.Context, params *FindPetsParams) (*findPetsResponse, error) {...}

My use case is to code generate into a package in the internal directory and then import this into a public package. I want to define the interface to the generated ClientWithResponses code in the consuming public package but can't due to the private response. Currently I manually create the ClientWithResponses interface in the same package as the generated codegen. There's probably a few solutions:

  • Modify the response signature and make the response objects public. It would be a breaking change though and probably need a major version bump.
  • Auto generate a ClientWithResponsesInterface as is already done for the client with the ClientInterface

@jamietanna
Copy link
Collaborator

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

No branches or pull requests

4 participants