-
Notifications
You must be signed in to change notification settings - Fork 21
5. Environment property files
Until version 1.5.0 it was required to provide all parameters as Command-Line parameters like this:
api-import.bat -a samples/petstore.json -c samples/minimal-config.json -h localhost -u apiadmin -p changeme -clientAppsMode ignore -ignoreQuotas true
Starting from version 1.5.0 it is possible to declare general information, like username, password, host, ignoreQuotaSettings, etc. in a properties file located in the new conf
folder. These property-files can take in all parameters that are used & known before as command-line options. Of course, Command-Line-Options are still supported.
Also the Environment-Properties do support the staging concept as explained below. Take the following example:
api-import.bat -c samples/minimal-config-api-definition.json -s prod
With this instruction, the API-Configuration & API-Definition is loaded from the config-file and the tool will lookup required parameters based on the stage (or environment) prod in the following sequence:
- conf/env.properties --> Most generic parameters for all stages
- conf/env.prod.properties --> Specific parameters for the production environment (may override generic ones)
- Command-Line parameters --> Given command line parameters override environment files
By default the conf
folder is expected to be within installation folder from where Swagger-Promote is started. Same as it is shipped with the Swagger-Promote release page.
Starting with version 1.6.6-1 you can optionally set the environment variable: SWAGGER_PROMOTE_HOME
, which is used with precedence when set and must point to a folder containing the conf
folder. This is especially useful when using Swagger-Promote as part of the integration pipeline for instance using a Maven-Plugin as you don't have an installation structure.
Future plan, is maybe to use these property files even for enforcement of certain things, like the right security or tags on a given stage. Or use it to auto-inject some default stuff which are valid for all APIs on a stage.
An example environment file with all possible options is delivered in the release page: conf/env.prod.properties.sample
or you can see it here:
https://github.com/Axway-API-Management-Plus/apimanager-swagger-promote/blob/develop/modules/swagger-promote-core/src/main/assembly/conf/env.properties.sample
The following is a snapshot of what is possible:
#
# Use this file to control common settings for all stages.
#
# This user is the primary user
# might be an Admin or OrgAdmin
# username=orgAdminUserABC
# password=orgAdminPassword
# Admin-Credentials to use, when tool is started without
# an admin account. If an admin-account is provided this is ignored.
admin_username=apiadmin
admin_password=changeme
# Hostname the API-Manager is listening
host=api-manager.customer.com
# Port the API-Manager is listening. Defaults to 8075
port=8175
# Control how breaking changes should be applied. Defaults to false
force=true
# Controls how configured Client-Applications are treated. Defaults to add!
# clientAppsMode=add
clientAppsMode=ignore
# clientAppsMode=replace
# Controls how configured Client-Organizations are treated. Defaults to add!
# clientOrgsMode=add
# clientOrgsMode=ignore
clientOrgsMode=replace
# Controls how configured Quotas are treated. Defaults to add!
# quotaMode=add
# quotaMode=ignore
quotaMode=replace
# If set, the tool wont load the env.properties. Defaults to false.
# ignoreAdminAccount=true
# Controls if you would like to allow to replace or set the host parameter
# in the Swagger-File based on the configured backendBasepath.
# This is turned on by default!
# replaceHostInSwagger=false
# Normally, in case of an error created BE- or FE-API is rolled back, so that the
# API-Manager stays in a clean state.
# With this parameter you can turn off rollback if needed.
# rollback=false
☝️ Swagger-Promote has been discontinued and is replaced by the new APIM-CLI