openapi
openapi copied to clipboard
Type error thrown when schema uses oneOf
schema:
oneOf:
- type: array
- type: string
Will throw
Exception occurred: File "/Users/maxmurmann/opt/anaconda3/envs/bullhorn-apis/lib/python3.8/site-packages/sphinxcontrib/openapi/openapi30.py", line 282, in _httpresource type=param['schema']['type'], KeyError: 'type'
whereas I believe this should be a fine formatting for OpenAPI?
This is certainly valid OpenAPI.
This same issue occurs with anyOf, e.g.:
"schema": {
"anyOf": [
{
"type": "string",
"format": "date"
},
{
"type": "null"
}
],
}
which should also be valid OpenAPI.
Sphinx : 6.2.1 sphinxcontrib-openapi: 0.8.1
Can someone provide a minimal example of a full schema with this used that can be tested against?
This might be related to https://github.com/sphinx-contrib/openapi/issues/96
That issue has a possible workaround (the "experimental renderer") which I might try.
@stephenfin I'll see if I can get a minimal example together.
This issue seems to be related as well to #53, #54, and #113. The two latter also proposed fixing changes, though that was years ago, so I don't know if they can be copy-pasted. I'll definitely try the workaround mentioned in #96, but feel free to check out our current build failure on the PR linked to above where I mentioned this issue and let me know how I could help with a fix.
The issue does seem to lie with entries like {"name": "table", "in": "query", "required": false, "schema": {"anyOf": [{"type": "boolean"}, {"type": "null"}], "default": false, "title": "Table"}} in our openapi-v1.json. They are created automatically, in this case from line 28 of ixmp4/server/rest/iamc/datapoint.py, which type-hints table as bool | None.
If the contents of the log file are of any interest: sphinx-err-dzck2sih.log
With the workaround in #96, the docs "build successfully", but I still see
WARNING: unknown directive or role name: openapi:httpdomain
/home/fridolin/ixmp4/doc/source/devs/ixmp4.server/endpoints.rst:4: ERROR: Error in "openapi:httpdomain" directive:
unknown option: "examples".
.. openapi:httpdomain:: /openapi-v1.json
:examples:
:group:
The error can be fixed by removing :examples: and :groups: and using the supported options detailed in issue/96, but this doesn't solve the warning that the directive openapi:httpdomain seems to be unknown.
Resolved via https://github.com/sphinx-contrib/openapi/pull/143