Open HawaiianSpork opened 8 years ago
@HawaiianSpork Could you provide a template example that is using this feature?
@wcandillon I updated the method.mustache
template to include validation based on the new fields. Is that what you are looking for?
The value for $ref is a path to the definitions section of the spec containing the definition of that parameter. For instance:
{
"swagger": "2.0",
"basePath": "/",
"paths": {
"/rpc/login": {
"post": {
"tags": [
"(rpc) login"
],
"produces": [
"application/json"
],
"parameters": [
{
"required": false,
"in": "header",
"name": "Prefer",
"type": "string",
"enum": [
"params=single-object"
],
"description": "Preference"
},
{
"required": true,
"schema": {
"$ref": "#/definitions/(rpc) login"
},
"in": "body",
"name": "args"
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
}
},
"definitions": {
"(rpc) login": {
"required": [
"_username",
"_password"
],
"properties": {
"_username": {
"format": "text",
"type": "string"
},
"_password": {
"format": "text",
"type": "string"
}
},
"type": "object"
}
}
}
I pulled this request and merged with head and fixed the conflict. The merge was pretty much fine, just one small change to the line that has .contains() to change it to the new method name .includes(). I don't know if there is any way to generate a useful patch or anything to keep this PR up to date, but it was very useful to me and I'd like to see it merged.
Adds the capability to access body properties from inside templates by adding a new method.bodySchema property.
produces the following following method.bodySchema that can be used in the template:
This is similar to pull request #94 but only adds bodySchema.