Swagger-editor: Within an OperationObject, a ParametersObject doesn't accept in: path as a valid location

Created on 15 Jun 2018  路  3Comments  路  Source: swagger-api/swagger-editor

Q&A (please complete the following information)

  • Method of installation: Public hosted Testing
  • Swagger-Editor version: Public hosted @ https://editor.swagger.io
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.0.1
info:
  title: Foo OpenApi Spec
  version: 1.0.0
servers:
  - url: 'https://localhost/BasePath'
paths:
  '/Account/{id}':
    get:
      description: |-
      operationId: Account1
      parameters:
        - name: id
          in: path
          allowEmptyValue: true
          schema:
            type: integer
            format: int32
      responses:
        '200':
          description: |-

Swagger-Editor configuration options:
n/a - using editor.swagger.io as a validator

Describe the bug you're encountering

Validation error of OpenApi schema - within an OperationObject, a ParametersObject doesn't accept in: path as a valid location

To reproduce...

  1. Paste the above YAML into the editor on editor.swagger.io
  2. Read the Errors on the right side

Expected behavior

No validation Errors and for "path" to be an acceptable "in" location

Screenshots


image

validation schema validation error quality enhancement

Most helpful comment

The errors are misleading. The real issue is that the path parameter is missing required: true.

Also, allowEmptyValue only applies to query parameters but not path patameters.

All 3 comments

The errors are misleading. The real issue is that the path parameter is missing required: true.

Also, allowEmptyValue only applies to query parameters but not path patameters.

Keeping this around as a validation enhancement - the messaging here isn't great.

As is with most of these issues, the problem lies in the JSON Schema validator not being smart enough to make guesses about which anyOf a user intended, and instead complaining about not matching the anyOf itself... which is not useful.

I've opened a pull request (#1985) that will close this issue.

Here's what Swagger Editor reports with my changes:

Structural error at [鈥get.parameters.0
should have required property 'required'
missingProperty: required
Was this page helpful?
0 / 5 - 0 ratings

Related issues

SteveNewhouse picture SteveNewhouse  路  5Comments

korenlev picture korenlev  路  4Comments

rrberry picture rrberry  路  4Comments

radj picture radj  路  5Comments

variable picture variable  路  4Comments