Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issue #2173 OpenApi3.0.0 #2214

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

NamesNotRick
Copy link

πŸš€ 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?

  • To write docs
  • To write tests
  • To put Conventional Changelog prefixes in front of all my commits and run npm run lint

Copy link
Member

@kylef kylef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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),
  },
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants