jreece
jreece

Reputation: 120

Swagger ... query-parameter properties access from Mustache

I'm using Mustache with swagger-codegen to generate model-entities from definitions, and code from operations (paths section). Each operation specifies a list of parameters, and other parameter attributes - datatype, description, default-value, required, maximum, example, etc.

I cannot work out how to access any parameter property besides the 'required' attribute ... except in the 'model' phase ... how can I do this in the 'api' phase ? ... I'd like to be able to drop code that verifies that the parameters meet conditions beyond 'required', like min/max, etc.

Upvotes: 1

Views: 978

Answers (1)

fehguy
fehguy

Reputation: 6824

you have some options for accessing parameter properties.

First off, I assume you're using swagger-codegen 2.1.0-M2 or a later snapshot. There are a number of properties available for each parameter, but they are currently not quite as rich as in the model properties.

To see what you have access to, please run the codegen with debug flags, which will print out all the information available to you in the templates:

java -DdebugOperations -jar swagger-codegen-cli.jar \
      generate \
     -i http://petstore.swagger.io/v2/swagger.json \
     -l java \
     -o samples/client/petstore/java

The other debug flags are:

# print out the interpreted swagger spec
-DdebugSwagger

# print out model info
-DdebugModels

# print out supporting file data
-DdebugSupportingFiles

Upvotes: 3

Related Questions