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

Incompatiable with OpenApi 3.0.1 #107

Open
kulsingh0 opened this issue Jan 28, 2021 · 8 comments · May be fixed by #159
Open

Incompatiable with OpenApi 3.0.1 #107

kulsingh0 opened this issue Jan 28, 2021 · 8 comments · May be fixed by #159

Comments

@kulsingh0
Copy link

Brief Introduction:
We are facing issues while generating the sphinx documentation while using openAPI 3.0.1 yml template files .
But it works successful with the Swagger 2.0 template.

Ask:
Can you please confirm if sphinx supports OpenAPI 3.01 templates for documentation?

Problem Statement :
Specifically, we are facing issues for following parameters in documentation.
a) Request Json Parameters
b) Response Json Parameters

As per below example of Open API 3.01 template it expects
image
( schema property is child of content)

where as in Swagger 2.0 the structure looks like this.
image

if we use the Swagger 2.0 yml to generate the HTML documentation then I successfully generates the Request JSON Parameter and Response JSON Parameters as below.
image

where as with former with openAPI 3.0.1 template it failed to load these request Json parameter and response Json Parameters
image

You can refer any sample open API 3.0.1 template from internet to reproduce this issue.

Really appreciate your prompt support.

@kulsingh0
Copy link
Author

Any update please?

@igo95862
Copy link

@kulsingh0 Try switching to new renderer on latest version. Add openapi_default_renderer='httpdomain' to conf.py

@rokroskar
Copy link

@igo95862 that doesn't seem to solve the problem for me:

Sphinx==3.4.3
sphinxcontrib-httpdomain==1.7.0
sphinxcontrib-openapi==0.7.0

It also doesn't work on the test API spec: https://github.com/sphinx-contrib/openapi/blob/master/tests/testspecs/v3.0/petstore-expanded.yaml

Yields:

image

@rabernat
Copy link

I recently discovered this issue (xref pangeo-forge/pangeo-forge-orchestrator#28). In that project, we are trying to include API documentation from a fastapi api object directly in a sphinx website. I imagine this is a very common scenario for python devs in 2022. We accomplish this with the following simple code in conf.py.

import yaml
from pangeo_forge_orchestrator.api import api  # created by FastAPI()

api_spec = api.openapi()  # openapi-style dictionary 
with open("openapi.yaml", mode='w') as fp:
    yaml.dump(api_spec, fp)

Plus the following RST in our sphinx site

.. openapi:: openapi.yaml

Fastapi exports openapi 3.0.x style metadata. The bug described here means that response and request JSON are not rendered. (See example site.)

We see two possible options to resolve the problem:

  • Implement a manual translation step, wherein we reformat api_spec to use the swagger-style nesting of response objects
  • Help resolve this problem upstream, i.e. in sphinxcontrib.openapi

Would the maintainers be willing to sketch out a roadmap of what it would take to fix this bug? We may be able to allocate developer time to such an effort if the path is clear.

@aleksandergabriel
Copy link

aleksandergabriel commented Jul 12, 2022

I just noticed the same problem.
Sphinx==4.5.0
sphinxcontrib-httpdomain==1.8.0
sphinxcontrib-openapi==0.7.0

Adding openapi_default_renderer='httpdomain' to conf.py, also did not solve the problem for me.

Is there a timeline when solution can be expected?

@david-i-berry
Copy link

This issue appears to be related to the resolution of references in the schemas.

The line

utils.normalize_spec(spec, **self._options)

Appears to be missing from the new renderer. Inserting this line at

and updating the includes (plus openapi_default_renderer='httpdomain') resolves the issue for me.

david-i-berry added a commit to david-i-berry/sphinxcontrib-openapi that referenced this issue Jul 4, 2023
@david-i-berry
Copy link

I've made a fork with the update applied at:

https://github.com/david-i-berry/sphinxcontrib-openapi

I've only tested with my use case but it renders as expected (i.e. with the request and response objects now shown).

@amhest
Copy link

amhest commented Sep 23, 2024

I just hit this issue with $ref in the responses on openapi 3.0.1. The fix from @david-i-berry on July 4, 2023 worked perfectly for me with both HTML and PDF. Any chance we can get this into a build?

sevdog added a commit to sevdog/openapi that referenced this issue Oct 15, 2024
Normalize spec before rendering in new httpdomain renderer
sevdog added a commit to sevdog/openapi that referenced this issue Oct 15, 2024
Normalize spec before rendering in new httpdomain renderer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants