Generate a data model from swagger spec
The toolkit allows for generating go native structures to serialize and validate a swagger compliant model definition.
The generated objects follow the specified validation rules, including extended format directives for strings and numbers.
Generated models support most Swagger 2.0 features, including polymorphism.
Generated models support most JSON-schema draft4 features, including AllOf
, AdditionalProperties
and AdditionalItems
.
Usage
generate model -f {spec}
See the full list of available options here.
Model building rules
- Schema generation rules
- About schemas
- Interfaces
- Mapping patterns
- Swagger vs JSONSchema
- Go-swagger vs Swagger
- Known limitations with go-swagger models
- Custom extensions
- Primitive types
- Formatted types
- Nullability
- Validation
- Type aliasing
- Extensible types
- Polymorphic types
- Serialization interfaces
- External types
- Customizing struct tags