Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type error thrown when schema uses oneOf #112

Closed
maxmurmann opened this issue Jul 29, 2021 · 8 comments
Closed

Type error thrown when schema uses oneOf #112

maxmurmann opened this issue Jul 29, 2021 · 8 comments

Comments

@maxmurmann
Copy link

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?

@freddrake
Copy link

This is certainly valid OpenAPI.

@khorn
Copy link

khorn commented Aug 9, 2023

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

@stephenfin
Copy link
Member

Can someone provide a minimal example of a full schema with this used that can be tested against?

@khorn
Copy link

khorn commented Aug 14, 2023

This might be related to #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.

@glatterf42
Copy link
Contributor

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.

@glatterf42
Copy link
Contributor

If the contents of the log file are of any interest: sphinx-err-dzck2sih.log

@glatterf42
Copy link
Contributor

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.

stephenfin added a commit to glatterf42/openapi that referenced this issue Oct 19, 2023
Signed-off-by: Stephen Finucane <[email protected]>
glatterf42 added a commit to glatterf42/openapi that referenced this issue Oct 20, 2023
@stephenfin
Copy link
Member

Resolved via #143

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants