litestar-org / litestar

Production-ready, Light, Flexible and Extensible ASGI API framework | Effortlessly Build Performant APIs
https://litestar.dev/
MIT License
5.53k stars 378 forks source link

Bug: ExternalDocumentation for ScalarRenderPlugin #3583

Open cringelord000222 opened 4 months ago

cringelord000222 commented 4 months ago

Summary

Hi there,

From what I've tried (v2.9.0), ExternalDocumentation only works on redoc and swagger, among the few litestar examples given in OpenAPI UI Plugins.

Would love to have it on Scalar as well (ScalarRenderPlugin), since I read that it's going to be the default plugin for v3.0.0.

Not sure if this is the correct place to ask, but thanks in advance.

Basic Example

FYI, this is the rough code that I used:

from litestar.app import Litestar
from litestar.openapi import OpenAPIConfig
from litestar.openapi.plugins ScalarRenderPlugin,

from litestar.openapi.spec import ExternalDocumentation

Litestar(
    openapi_config=OpenAPIConfig(
        title="title",
        version="version",
        external_docs=ExternalDocumentation(
            url=project_metadata["project"]["urls"]["Repository"],
            description="Repository",
        ),
        render_plugins=[
            ScalarRenderPlugin(),
        ],
        path="/docs",
    )
)

Drawbacks and Impact

None

Unresolved questions

None


[!NOTE]
While we are open for sponsoring on GitHub Sponsors and OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.

Check out all issues funded or available for funding on our Polar.sh dashboard

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
  • This, along with engagement in the community, helps us know which features are a priority to our users.

Fund with Polar

JacobCoffee commented 4 months ago

If this isnt working it may be a bug. I think Scalar supports ExternalDocumentation (https://github.com/search?q=repo%3Ascalar%2Fscalar%20ExternalDocumentation&type=code)

cringelord000222 commented 4 months ago

If this isnt working it may be a bug. I think Scalar supports ExternalDocumentation (https://github.com/search?q=repo%3Ascalar%2Fscalar%20ExternalDocumentation&type=code)

I've downloaded the spec.json and the externalDocs section does exist. It's just that this part is not rendering in the frontend.

# within spec.json

"externalDocs": {
    "url": "https://github.com/litestar-org/litestar",
    "description": "Repository"
  }
JacobCoffee commented 3 months ago

MCVE

  1. Set up app.py:
    
    from litestar.app import Litestar
    from litestar.openapi import OpenAPIConfig
    from litestar.openapi.plugins import ScalarRenderPlugin

from litestar.openapi.spec import ExternalDocumentation

app = Litestar( openapi_config=OpenAPIConfig( title="title", version="version", external_docs=ExternalDocumentation( url="https://docs.litestar.dev", description="Repository", ), render_plugins=[ ScalarRenderPlugin(), ], ) )


2. Install deps `pip install litestar[standard]`
3. Run app: `litestar run --debug`
4. Open page: `open "https://127.0.0.1:8000/schema/"`

No docs