Invalid specification is generated
spinenkoia opened this issue · comments
The documentation says:
.. code-block:: python3
from aiohttp import web
from aiohttp_pydantic import oas
app = web.Application()
oas.setup(app)
But when you contact the address http://127.0.0.1:8080/oas/spec
Returns a specification that is not valid for swagger
Here's the mistake
Structural error at
should have required property 'info' missingProperty: info
Jump to line 0
In the list, you need to return the "Info" attribute
Could you show me the code of your PydanticView? or better send me or minimal, complete reproducible example?
This is reproduced on the demo pydantic_aiohttp
git clone https://github.com/Maillol/aiohttp-pydantic.git
cd aiohttp-pydantic
python3 -m demo
The problem is that https://github.com/Maillol/aiohttp-pydantic/blob/main/aiohttp_pydantic/oas/view.py#L154 not configurable "info" field
I would suggest passing this in setup(), or at least setting it by default in OpenApiSpec3
I'll make a merge request later
Ok this part is missing. https://swagger.io/specification/#info-object
Currently you can create a json file with info property and generate the spec using the aiohttp-pydantic command line with
--base-oas-file
option but, sadly they are no mechanism to add info property to the spec returned by the route /oas/spec
.
Your MR is welcome.
I thinks is a good idea to add a parameter to setup(). and pass info to generate_oas
function like we pass the "apps to expose".
Tips: In the generate_oas you can do
oas.info.terms_of_service = ...
oas.info.version = ...
To set the info fields to the oas spec.
@Maillol can I write to you in a telegram ? we want to use your project, but there are a few questions. but we are ready to provide support
I don't have a telegram account. Do you have a Keybase Chat ?
I istalled ispinenko my login
released in 1.9.0