#3275·go-swagger

question(generate spec) : generating spec from go types, specify required without explicit comment

Author: axel7083Created Dec 12, 2025Updated Jul 20, 2026
Labelsenhancementgenerate spec

I was experimenting with the swagger output generated using go-swagger in a repository, and I combined it with swagger-typescript-api to generate typescript types, however I noticed that everything is optional by default. Making the generated types pretty unusable.

However, the go-swagger generate spec is nicely adding the x-nullable to all properties that may be null; moreover the go struct use nicely the json synthax json:"<name>,omitempty" to specify if something may be missing. Isn't it enough to specify in the other cases that something is required?

I understand that we can add the // required:true annotation, but in a codebase with hundreds of struct, this may takes some time, so asking for guidance. Thanks !