Conversation
kylef
left a comment
There was a problem hiding this comment.
I don't believe this pull request does what you expect it does. As schema is not a property passed down by the caller. It's not quite that simple to implement schema support unfortunately.
Schema Object's inside a Parameter Object in OpenAPI 3 is not supported in the underlying parser and therefore Dredd will not be able to access it. Dredd solely deals with two internal formats: API Elements, and then Dredd's own format (this the validateParams is taking Dredd's own format). Dredd itself doesn't really interoperate with underlying description formats like API Blueprint, Swagger 2 or OpenAPI. Instead it uses API Elements parsers to return "API Elements" which provides a uniform structure for numerous description formats (so that Dredd does not have to deal with the differences between formats). Then dredd-transactions package converts API Element's structures from API Element's into Dredd transaction format. That is what the compileParams function is doing.
It would be appropriate to add this into the OpenAPI 3 parser used, there's an existing issue tracking this: apiaryio/api-elements.js#226
| case 'boolean': | ||
| if ((param.example !== 'true') && (param.example !== 'false')) { | ||
| text = `URI parameter '${paramName}' is declared as 'boolean' but it is not.`; | ||
| if (param.schema && param.schema.example && typeof param.example === 'string'){ |
There was a problem hiding this comment.
The param structure does not contain a schema property. See the implementation of compileParams which the result is passed to validateParams.
return {
[name]: {
required: getRequired(memberElement),
default: getDefault(valueElement),
example: getExample(valueElement),
values: getValues(valueElement),
},
};
🚀 Why this change?
JSON parsing (validateParams) doesn't support the new OpenApiV3.0.0 JSON formatting
📝 Related issues and Pull Requests
Issue #2173
✅ What didn't I forget?
npm run lint