Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants