Open jmchilton opened 1 year ago
Eliminating just that route from the JSON/YAML doc allows making some progress.
Update: Just getting rid of that exclusiveMaximum element allows generation.
It does look like that client isn't ready for 3.1 yet (pydantic generates 3.1, except it's forced to 3.0 for swagger):
Error(s) encountered while generating, client was not created
Failed to parse OpenAPI document
7 validation errors for OpenAPI
paths -> /api/pages -> get -> parameters -> 6 -> schema -> $ref
field required (type=value_error.missing)
paths -> /api/pages -> get -> parameters -> 6 -> schema -> exclusiveMaximum
value could not be parsed to a boolean (type=type_error.bool)
paths -> /api/pages -> get -> parameters -> 6 -> $ref
field required (type=value_error.missing)
openapi
unexpected value; permitted: '3.0.0' (type=value_error.const; given=3.1.0; permitted=('3.0.0',))
openapi
unexpected value; permitted: '3.0.1' (type=value_error.const; given=3.1.0; permitted=('3.0.1',))
openapi
unexpected value; permitted: '3.0.2' (type=value_error.const; given=3.1.0; permitted=('3.0.2',))
openapi
unexpected value; permitted: '3.0.3' (type=value_error.const; given=3.1.0; permitted=('3.0.3',))
OK, to summarize the status:
pydantic generates OpenAPI 3.1.0 documents, and FastAPI forces the schema to 3.0.2, even though it isn't.
exclusiveMaximum
is a boolean in 3.02 and a number in 3.1.0.
I've changed the dumping script to produce 3.1.0 as the version, fixed a bunch of invalid things in https://github.com/galaxyproject/galaxy/pull/15183 and #15189 and added linting for the generated schema.
I'm trying to use https://github.com/commonism/aiopenapi3/, which can generate pydantic models, and is supposed to work for recursive models, but it seems that doesn't quite work for our recursive models:
from aiopenapi3 import OpenAPI
import json
js = json.load(open('_schema.json'))
OpenAPI(url="http://localhost:8080/galaxy", document=js)
The 3.0.3 was so close - I had Python artifacts. My next step would be just to parameterize that and hack the schema when passed 3.0.X in our utils. It seems you prefer the aio clients though and that is fine - willing to give you time if fixing bugs in that project is your preferred route.
Hi,
it will parse properly now. You've had recursion in a list which was not handled properly before https://github.com/commonism/aiopenapi3/pull/55/commits/2687f25434298b90c3121cfed7b5d370e91a661e.
If you stick with aiopenapi3, please @commonism when discussing the OpenAPI problems you run into.
Awesome, thanks so much!
It seems you prefer the aio clients though
aiopenapi3 does both. https://github.com/commonism/aiopenapi3#asyncio
sync is nice for the first steps - usually debugging the description document mismatches. beyond - async is great
Things I'd change with the description document:
operationId: decode_id_api_configuration_decode__encoded_id__get
- horrible, but I've seen worse already.additionalProperties
limits the compatible (python) libraries, similar to the "recursive" experience you've already had. Once you mix additionalProperties
with properties
aiopenapi3 won't serve you as well. head
- display_api_datasets__history_content_id__display_head
, not seen before, I expect it to work, but you'll find out.use_operation_tags=True
, access via …._.TAG.operationId .
Not working yet...