playpauseandstop / rororo

Implement aiohttp.web OpenAPI 3 server applications with schema first approach.
https://rororo.readthedocs.io
BSD 3-Clause "New" or "Revised" License
105 stars 9 forks source link

OpenAPI schema validation #233

Open fajfer opened 2 years ago

fajfer commented 2 years ago

Hey, thank you for creating this repository, I really like it on paper and hopefully I'll be able to utilize and contribute as much as I can :)

I just spend a good amount of time wondering why my schema doesn't work, I've validated it using Redocly OpenAPI extension in VSCode, I've used Swagger editor and validated (as the error suggests) using openapi-spec-validator package. Turns out my scheme is ok but rororo would not accept it anyway, to have some context this is the error I'm speaking about:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File ".py", line 10, in run
    return setup_openapi(
  File "/lib/python3.8/site-packages/rororo/openapi/openapi.py", line 726, in setup_openapi
    raise ConfigurationError(
rororo.openapi.exceptions.ConfigurationError: Unable to load valid OpenAPI schema in openapi.yaml. In most cases it means that given file doesn't contain valid OpenAPI 3 schema. To get full details about errors run `openapi-spec-validator /home/centos/git/omni/devops/odra/src/openapi.yaml`

I've been trying to break/fix my code in many ways but managed to fix it by adding quotation marks to every string in my file, so instead of doing this (which is acceptable by all other validators):

  contact:
    name: Damian Fajfer

rororo requires me to write it with quotation marks:

  contact:
    name: "Damian Fajfer"

My guess is there's no reason for enforcing quotation marks and both versions should work, correct?

playpauseandstop commented 1 year ago

@fajfer

Yeah, your assumption is correct,

  contact:
    name: Damian Fajfer

is completely correct OpenAPI schema, my only guess the error caused by obsolete version of openapi-spec-validator, which still supported by rororo, but I plan to fix this in #149

If you're still interested, please buckle up 😎