`Failed validating 'oneOf' in schema['properties']['paths']['patternProperties']['^\\/']['patternProperties']['^(get|put|post|delete|options|head|patch|trace)$']['properties']['parameters']['items']:`

Open
#116 2 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
openapi, python

Research direction

Reproduce the minimal OpenAPI 3.0 document with openapi-spec-validator 0.3.0 and 0.2.10, focusing on the referenced query parameter under paths / get. Check the OpenAPI parameter rules and validator behavior when example and examples are both present. Done means establishing whether the validator behavior matches the specification and documenting or correcting the discrepancy.

Written by the indexing model from the issue text.

Description

kind/question

I get:

{'in': 'query', 'name': 'bar', 'example': '1', 'examples': {'1': {'summary': '1', 'value': '1'}, '2': {'summary': '2', 'value': '2'}}, 'schema': {'type': 'string'}} is not valid under any of the given schemas

Failed validating 'oneOf' in schema['properties']['paths']['patternProperties']['^\\/']['patternProperties']['^(get|put|post|delete|options|head|patch|trace)$']['properties']['parameters']['items']:
    {'oneOf': [{'$ref': '#/definitions/Parameter'},
               {'$ref': '#/definitions/Reference'}]}

On instance['paths']['/']['get']['parameters'][0]:
    {'$ref': '#/components/parameters/foo',
     'x-scope': ['file:///usr/share/ucs-test/73_udm-rest/openapi2.json']}

for

{
    "components": {
        "parameters": {
            "foo": {
                "in": "query",
                "name": "bar",
                "example": "1",
                "examples": {
                    "1": {
                        "summary": "1",
                        "value": "1"
                    },
                    "2": {
                        "summary": "2",
                        "value": "2"
                    }
                },
                "schema": {
                    "type": "string"
                }
            }
        }
    },
    "info": {
        "description": "",
        "title": "",
        "version": "1.0.0"
    },
    "openapi": "3.0.0",
    "paths": {
       "/": {
            "get": {
                "parameters": [
                    {
                        "$ref": "#/components/parameters/foo"
                    }
                ],
                "responses": { "200": {"description": "", "content": {"text/plain": {"schema": {"type": "string"}}}} }
            }
        }
    }
}

since openapi-spec-validator==0.3.0. It succeeded to validate with openapi-spec-validator==0.2.10.
If I remove one of example or examples from #/components/parameters/foo the validation succeeds.

Does openapi define them as mutually exclusive?
https://swagger.io/docs/specification/adding-examples/ doesn't seem to contain a mix. The swagger UI just sucks in displaying examples.

Dominant language
Python
Stars
409
Forks
73
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python-openapi/openapi-spec-validator

All issues in python-openapi/openapi-spec-validator

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.