Open mm-gmbd opened 8 years ago
@mm-gmbd which are the body parameters you are referring to? In the swagger sample above I see only one named body
. Given the swagger sample above, could you send me an example of expected generated source code? It would help to understand the issue a bit better.
@wcandillon, sorry for the late reply. Correct, there is only one parameter named body
, and that is actually enforced by the swagger spec itself:
Since there can only be one payload, there can only be one body parameter. The name of the body parameter has no effect on the parameter itself and is used for documentation purposes only.
Also:
If in is "body":
Field Name | Type | Description |
---|---|---|
schema | Schema Object | Required. The schema defining the type used for the body parameter. |
The schema
object that must be included if the parameter is a body parameter defines the actual schema of the body. Therefore, whatever is in the schema
object are actually the body parameters that should be cared about. In the example above, this would be prop1
, and this is not currently accessible via the mustache variables.
I've forked this and can provide a PR with my changes. They are somewhat quick and dirty, but it may help provide some insight into what I'm after.
I'm not sure if this is me misunderstanding the Swagger specification, or if this is a bug, but I'll go ahead and lay it out.
According to the specification, a Path Item Object can contain a field named
parameters
, which is an array of either Parameter Objects or Reference Objects. Let's focus on the parameter objects.The parameter object contains a number of fields, including the required field
in
. This field can be one of the following possible values: "query", "header", "path", "formData" or "body".In my case, I have a Swagger, in one of my Path Item Objects, I have a singular parameter object in my
parameters
field. This singular parameter object'sin
field is set tobody
. According to the specification, ifin
is set tobody
, another parameter must be present,schema
, which is of type Schema Object, which is based on the JSON Schema Specification Draft 4.In this schema object, I can define one to many
properties
that should essentially be considered body parameters. But, my issue is that the template variableparameters
does not contain the variables that are defined as body parameters, it only contains one parameter namedbody
.Here is my swagger:
And here is the resulting Node.js code, specifically the portion that uses the method
isBodyParameter
:There is no mention of the body parameter
param1
. It would be very helpful if, when one of the Swagger parameters is inbody
and there is aschema
defined, those body parameters would be accessible via the template variables.Ideas / comments?
Thanks, -Max