API Layer Generator from the OpenAPI specification.
This project is using the OpenAPI Generator and provides a set of plugins for it. Primary target is a golang, however other languages to be considered in the future.
Project status: pre-alpha.
- Installation and usage instructions
- Documentation on generated code structure and suggested patterns
- enums
- simple types directly in body
- array types directly in body
- allow handling as plain http handler
- authentication
- per route middleware
- polymorphic models
Set of features compatible with golang
Some language specific features may be challenging (if possible) to implement correctly. The Language specific caveats summarises various implementation details.
Supported serialization styles:
parameter location | style | explode | example primitive type | example array type | object support |
---|---|---|---|---|---|
path | simple | false | /users/5 |
/users/3,4,5 |
- |
query | form | true | /users?id=5 |
/users?id=3&id=4&id=5 |
- |
type | required | nullable |
---|---|---|
string | ✓ | ✓ |
number/integer | ✓ | ✓ |
boolean | ✓ | ✓ |
object | ✓ | ✓ |
array | ✓ | ✓ |
format | in | minLength | maxLength | pattern |
---|---|---|---|---|
none or custom | query,path,body | ✓ | ✓ | ✓ |
date | query,path,body | - | - | - |
date-time | query,path,body | - | - | - |
byte | query,path,body | ✓ | ✓ | - |
type | format | in | minimum | maximum |
---|---|---|---|---|
number | - | query,path | ✓ | ✓ |
number | float | query,path,body | ✓ | ✓ |
number | double | query,path,body | ✓ | ✓ |
integer | - | query,path,body | ✓ | ✓ |
integer | int32 | query,path,body | ✓ | ✓ |
integer | int64 | query,path,body | ✓ | ✓ |
type | in | supported? |
---|---|---|
boolean | query,path,body | ✓ |
Objects are only supported in request body of application/json
content type.
items type | in | minItems | maxItems |
---|---|---|---|
string | query,path,body | ✓ | ✓ |
number | query,path,body | ✓ | ✓ |
integer | query,path,body | ✓ | ✓ |
boolean | query,path,body | ✓ | ✓ |
object | body | ✓ | ✓ |
Golang:
date
type in request body is parsed as time.Time RFC3339Nanorequired
in request body has the following constraints:- The
required
check on booleans in request body is not performed - For simple data types - will validate if the field is non default
- For objects - optional and nullable are synonyms. This means that required validation will only work for non nullable fields.
- The
array
fieldsrequired
is equivalent tominItems: 1
nullable
arrays are only supported in request body- nullable and optional array fields are synonyms
Please have the following tools installed:
Review Customization docs of openapi generator cli.
Build particular generator:
mvn -f generators/go-apigen-server/ package
Generate code using a particular generator (will build if needed):
make generate/golang
Run tests
make tests