Make sure to install nodejs and npm and execute the following in the root project
npm installMake sure to add ANYPOINT_GENERATOR_GO_DEST environment variable that should point to the destination go folder. You can use the dist folder of the project which is ignored in git by executing the following inside the project's folder:
export ANYPOINT_GENERATOR_GO_DEST=`pwd`/distUse the following to get the manual
npx openapi-generator-cli helpUse the following command to generate using the configuration stored in openapitools.json
npx openapi-generator-cli generateHere's some rules to keep in mind when you write your spec:
- Use OAS 3.0.0
- Define your objects schemas in
#/components/schemaand reference them in your path definitions. - Use enheritance and polymorphism when you define your schemas to avoid redefining the same attributes multiple times. ref.
- For each attribute of your schemas make sure to provide a
title. Thetitlewill be used to generate a structure name for that attribute, therefore use a short and consitent name. look in the existent specs for examples. - Use caml case in
titleto name your schemas attributes. - When using
titleto describe an object or array, its name should be unique accross the same specification. - For each of your api resource, return a deterministic result and never user OneOf for example. The generator will not be able to create the appropriate Type.
- For all simple types (e.g integer, string ...) Don't use
$refto refer to the definition. - Make sure to remove any unnecessary
requiredattributes. - Though the use of body parameter is discouraged for
DELETEoperations, some APIs may require it (to delete multiple specific items for example...). In that case some editors like Swagger may show an error when you add arequestBodyon aDELETEresource operation. Don't pay attention to that error since our code generator supports it. If you are annoyed by that, try using your favorite editor's plugin for openapi (example on vscode openapi plugin). - If a given field supports multiple types, don't use
oneOforanyOf. Instead, leave the type empty (add title field or description only for example). - Use
operationIdto name resources..
- open api generator
- openapi placeholders maven
- openapi cli placeholders
- JSON to JSONSchema Converter Tool
This is an open source software, please review the considerations. This is an open source project, it does not form part of the official MuleSoft product stack, and is therefore not included in MuleSoft support SLAs. Issues should be directed to the community, who will try to assist on a best endeavours basis. This application is distributed as is.