swagger-api / swagger-api/swagger-codegen
Validation specified in parameters -> schema do not show in mustache tags?
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
It appears that validation parameters (min/max, length, items, etc) that are put into the parameters { schema { } } (such as for body parameters) do not show up in codegen mustache tags and cannot be used to validate input.
Is this intended or missing functionality?
Swagger-codegen version
HEAD
Swagger declaration file content or url
{
"description":"A list of contacts to edit",
"in":"body",
"name":"contact_ids",
"required":true,
"schema":{
"description":"contact_ids array",
"items":{
"description":"ID of the contact to edit",
"format":"int32",
"title":"delete_characters_character_id_contacts_contact_id",
"type":"integer"
},
"maxItems":20,
"minItems":1,
"title":"delete_characters_character_id_contacts_contact_ids",
"type":"array"
}
},
Mustache output:
{
"isBodyParam" : true,
"hasMore" : true,
"isContainer" : true,
"secondaryParam" : true,
"isPrimitiveType" : true,
"baseName" : "contact_ids",
"paramName" : "contactIds",
"dataType" : "[]int32",
"description" : "A list of contacts to edit",
"unescapedDescription" : "A list of contacts to edit",
"jsonSchema" : "{\r\n \"in\" : \"body\",\r\n \"name\" : \"contact_ids\",\r\n \"description\" : \"A list of contacts to edit\",\r\n \"required\" : true,\r\n \"schema\" : {\r\n \"title\" : \"delete_characters_character_id_contacts_contact_ids\",\r\n \"type\" : \"array\",\r\n \"description\" : \"contact_ids array\",\r\n \"items\" : {\r\n \"type\" : \"integer\",\r\n \"format\" : \"int32\",\r\n \"description\" : \"ID of the contact to edit\",\r\n \"title\" : \"delete_characters_character_id_contacts_contact_id\"\r\n }\r\n }\r\n}",
"isBinary" : false,
"isListContainer" : true,
"isEnum" : false,
"vendorExtensions" : {
"x-exportParamName" : "ContactIds"
},
"required" : true
},
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how the parameters { schema { } } content is turned into codegen Mustache parameter tags, using the provided body-parameter example as the reproduction case. Determine whether schema validations such as minItems and maxItems are intentionally omitted or lost, and consider the issue complete when the intended behavior is established and covered by an appropriate regression check.
Written by the indexing model from the issue text.
Assessment
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100