-
-
Notifications
You must be signed in to change notification settings - Fork 772
OpenAPI: 'required' not working on 'allOf' related properties #785
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
Comments
Can you please file this against openapi-spec-validator? I'm happy to look
into it over there.
…On Fri, Nov 16, 2018, 7:21 PM tobuh ***@***.***> wrote:
Description
Using 'required' on properties from objects referenced by 'allOf' leads to
error "connexion.exceptions.InvalidSpecification"
Expected behaviour
Using 'required' should not throw an error for properties from 'allOf'
Actual behaviour
Error thrown:
Traceback (most recent call last):
File "test.py", line 4, in
app.add_api('restapitest.yaml')
File
"/home/tobias/.local/lib/python3.5/site-packages/connexion/apps/flask_app.py",
line 54, in add_api
api = super(FlaskApp, self).add_api(specification, **kwargs)
File
"/home/tobias/.local/lib/python3.5/site-packages/connexion/apps/abstract.py",
line 155, in add_api
options=api_options.as_dict())
File
"/home/tobias/.local/lib/python3.5/site-packages/connexion/apis/abstract.py",
line 72, in *init*
self.specification = Specification.load(specification, arguments=arguments)
File "/home/tobias/.local/lib/python3.5/site-packages/connexion/spec.py",
line 151, in load
return cls.from_file(spec, arguments=arguments)
File "/home/tobias/.local/lib/python3.5/site-packages/connexion/spec.py",
line 108, in from_file
return cls.from_dict(spec)
File "/home/tobias/.local/lib/python3.5/site-packages/connexion/spec.py",
line 146, in from_dict
return OpenAPISpecification(spec)
File "/home/tobias/.local/lib/python3.5/site-packages/connexion/spec.py",
line 39, in *init*
self._validate_spec(raw_spec)
File "/home/tobias/.local/lib/python3.5/site-packages/connexion/spec.py",
line 232, in _validate_spec
raise InvalidSpecification.create_from(e)
connexion.exceptions.InvalidSpecification: Required list has not defined
properties: ['name']
Steps to reproduce restapi.yaml
openapi: 3.0.0
info:
description: Test
version: 0.1.0
title: "Test API"
paths:
/objects:
get:
summary: "Get all available objects"
operationId: getObjects
responses:
200:
description: "List of available objects"
content:
application/json:
schema:
type: "array"
items:
allOf:
- $ref: '#/components/schemas/AnotherObject'
default:
description: "standard error"
components:
schemas:
Object:
type: "object"
properties:
name:
type: "string"
example: "Testname"
AnotherObject:
required:
- name
allOf:
- $ref: '#/components/schemas/Object'
- type: "object"
properties:
anotherproperty:
type: "string"
test.py
import connexion
app = connexion.App(__name__, specification_dir='./')
app.add_api('restapitest.yaml')
app.run(port=8080)
Additional info:
Output of the commands:
- python3 --version = Python 3.5.2
- pip3 show connexion | grep "^Version\:" = Version: 2.0.2
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#785>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAlPSUxmzvm_BvqYgI4TApfhtPEhUTRvks5uvnWRgaJpZM4Ylu6a>
.
|
You pointed me in a good direction. It seems, thats it already mentioned there?? |
Ok, it seems that the syntax was not as expected. Now I'm using:
The error is gone. But editor.swagger.io accepted the former definition as well ... which was a bit misleading ... Now my project is starting. Thank again for pointing me in the right direction ... |
sure thing @tobuh |
Uh oh!
There was an error while loading. Please reload this page.
Description
Using 'required' on properties from objects referenced by 'allOf' leads to error "connexion.exceptions.InvalidSpecification"
Expected behaviour
Using 'required' should not throw an error for properties from 'allOf'
Actual behaviour
Error thrown:
Steps to reproduce
restapitest.yaml
test.py
Additional info:
Output of the commands:
python3 --version
= Python 3.5.2pip3 show connexion | grep "^Version\:"
= Version: 2.0.2The text was updated successfully, but these errors were encountered: