Forum Discussion

exuraz's avatar
exuraz
New Contributor
6 years ago

Required list has not defined properties: ['type']

Hi,

 

Generating a python-flask server stub for OpenTripModel (using OAS 3) works but when trying to run the server gives the following error:

Traceback (most recent call last):
File "c:\python37\Lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\python37\Lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Julian\Downloads\server\openapi_server\__main__.py", line 18, in <module>
main()
File "C:\Users\Julian\Downloads\server\openapi_server\__main__.py", line 13, in main
pythonic_params=True)
File "C:\Users\Julian\.virtualenvs\server-Cq-s3KBS\lib\site-packages\connexion\apps\flask_app.py", line 54, in add_api
api = super(FlaskApp, self).add_api(specification, **kwargs)
File "C:\Users\Julian\.virtualenvs\server-Cq-s3KBS\lib\site-packages\connexion\apps\abstract.py", line 155, in add_api
options=api_options.as_dict())
File "C:\Users\Julian\.virtualenvs\server-Cq-s3KBS\lib\site-packages\connexion\apis\abstract.py", line 73, in __init__
self.specification = Specification.load(specification, arguments=arguments)
File "C:\Users\Julian\.virtualenvs\server-Cq-s3KBS\lib\site-packages\connexion\spec.py", line 151, in load
return cls.from_file(spec, arguments=arguments)
File "C:\Users\Julian\.virtualenvs\server-Cq-s3KBS\lib\site-packages\connexion\spec.py", line 108, in from_file
return cls.from_dict(spec)
File "C:\Users\Julian\.virtualenvs\server-Cq-s3KBS\lib\site-packages\connexion\spec.py", line 146, in from_dict
return OpenAPISpecification(spec)
File "C:\Users\Julian\.virtualenvs\server-Cq-s3KBS\lib\site-packages\connexion\spec.py", line 39, in __init__
self._validate_spec(raw_spec)
File "C:\Users\Julian\.virtualenvs\server-Cq-s3KBS\lib\site-packages\connexion\spec.py", line 232, in _validate_spec
raise InvalidSpecification.create_from(e)
connexion.exceptions.InvalidSpecification: Required list has not defined properties: ['type']

There is no indication to where this error occurs in the swagger.yaml file so I have no idea how to fix this.

Swagger Editor and SwaggerHub both say the spec is valid, however running openapi-spec-validator returns the same error regarding Required list has not defined properties: ['type'], but does not give a location for that error either.

 

Is there any way to find this out?

      • HKosova's avatar
        HKosova
        SmartBear Alumni (Retired)
        exuraz wrote:

         

        It turned out the file has errors which are not detected by a lot of validators.

        I found an OpenAPI validator from IBM which does see them and gives line numbers to fix them:

        https://github.com/IBM/openapi-validator


        From a quick look the file seems to be a valid OpenAPI 3.0 definition. Most (if not all) errors and warnings reported by IBM's openapi-validator are NOT syntax errors but custom style validations based on "custom IBM-defined best practices" such as:

        Property names must be lower snake case.

        Arrays MUST NOT be returned as the top-level structure in a response body.
        Operations with non-form request bodies should set a name with the x-codegen-request-body-name annotation.

        These things aren't actually errors.