This project exports a data schema based on field collections, and an openapi schema for those fields.
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
docker run --rm -v `pwd`/data:/data kindservices/openapi-gen:latest 2>/dev/null > openapi.ymlIt takes as input a directory containing json files (which adheres to these types):
./data/user.json
{
"name": "User",
"fields": [
{ "name": "id", "type": "string", "required": true },
{ "name": "username", "type": "string", "required": true },
{ "name": "email", "type": "email", "required": true },
{ "name": "createdAt", "type": "date" }
]
}
./data/product.json
{
"name": "Product",
"fields": [
{ "name": "id", "type": "string", "required": true },
{ "name": "name", "type": "string", "required": true },
{ "name": "price", "type": "decimal", "required": true },
{ "name": "quantity", "type": "int", "required": true },
{ "name": "createdAt", "type": "date" }
]
}
And produces an open-api spec for reading that data (getting it by ID, listing or querying it):
...
/data/user/{id}:
get:
summary: Get User by ID
operationId: getUserById
parameters:
- name: id
in: path
required: true
schema:
type: string
responses:
'200':
description: A User
content:
application/json:
schema:
$ref: '#/components/schemas/User'
...