-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add support for extra tags and custom types #105
Comments
I am not opposed to this, but would love to see a more complete example (sample openapi spec and desired generated code) so that I better understand your use case. The main example I immediately think of is trying to map to existing types from a third party package. The first that comes to mind is geojson. But, this adds a lot of complexity and moves a bit away from the original goal of this project which is "schema first, then types". I could see something like Having said all of that, I still want to hear more about the exact issue you have and types you are currently trying to use. |
I see your point about the In my case I'm trying to use Playground Validator instead of the built in ozoo validation. In order to use it, I need to specify the validation rules inside the struct tags. OpenAPI order:
type: string
enum:
- asc
- desc
x-go-type: string
x-oapi-codegen-extra-tags:
validate: required,oneOf=asc desc Generated Code Order string `json:"order,omitempty" mapstructure:"order,omitempty" validate:"required,oneOf=asc desc"` Even outside of Playground validator, it would still be useful as a lot of other Golang validation libraries also rely on struct tags. Giving the user freedom to choose what validation library to use would also help adoption. |
I am curious, the models already come with validation. Your example uses Whenever possible, we have tried to use plain OpenAPI and default to the built-in features as much as possible, translating them to Go as good as possible. The intent the spec should be sharable with other teams using other languages. Adding more |
This package has everything I would ever want in a OpenAPI code generator for Golang but the package doesn't leave a lot of room for flexibility.
Adding something like
x-go-type
andx-oapi-codegen-extra-tags
like oapi-codegen that allows adding tags and overriding types would be awesome.The text was updated successfully, but these errors were encountered: