I'm using OpenAPI Generator cli to generate endpoint api service from template.yml
In my template i define server url in string and i would like to pass as a variable because i have dev env & prod env with differents url.
openapi: 3.0.0
servers:
- url: 'http://localhost:8080/MyApiCustom'
Can i pass options in cli command openapi generate which it can be use in template, or use env variable in template ?
Thanks for help !
Yes, this is entirely possible. OpenApi 3.x supports server templating. For example:
You can then define these variables in your cli using the following cli parameter:
--server-variables=env=dev,port=8098,path=devApi
This feature was added in this commit from 2019.
Note: you must have a default specified in your OAS file.