Maillol / aiohttp-pydantic

Aiohttp View that validates request body and query sting regarding the annotations declared in the View method
MIT License
67 stars 21 forks source link

Invalid specification is generated #12

Closed spinenkoia closed 3 years ago

spinenkoia commented 3 years ago

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

Maillol commented 3 years ago

Could you show me the code of your PydanticView? or better send me or minimal, complete reproducible example?

spinenkoia commented 3 years ago

This is reproduced on the demo pydantic_aiohttp git clone https://github.com/Maillol/aiohttp-pydantic.git cd aiohttp-pydantic python3 -m demo

Go to http://127.0.0.1:8080/oas/spec

spinenkoia commented 3 years ago

The problem is that https://github.com/Maillol/aiohttp-pydantic/blob/main/aiohttp_pydantic/oas/view.py#L154 not configurable "info" field

spinenkoia commented 3 years ago

I would suggest passing this in setup(), or at least setting it by default in OpenApiSpec3

spinenkoia commented 3 years ago

I'll make a merge request later

Maillol commented 3 years ago

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.

spinenkoia commented 3 years ago

@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

Maillol commented 3 years ago

I don't have a telegram account. Do you have a Keybase Chat ?

spinenkoia commented 3 years ago

I istalled ispinenko my login

Maillol commented 3 years ago

released in 1.9.0