google / docsy

A set of Hugo doc templates for launching open source content.
https://docsy.dev
Apache License 2.0
2.6k stars 895 forks source link

broken link on swagger ui #881

Open brunoamaral opened 2 years ago

brunoamaral commented 2 years ago

I'm seeing a broken to the json file when using the swaggerui shortcode.

The page has this content:

---
title: swaggerExample
linkTitle: swaggerExample
type: swagger
---

{{< swaggerui src="swaggerExample.json" >}}

It renders fine, but under the title it shows this:

image

<a target="_blank" href="about:blank" rel="noopener noreferrer" class="link">
<span class="url"><!-- react-text: 57 --> <!-- /react-text --><!-- react-text: 58 --> swaggerExample.json<!-- /react-text --><!-- react-text: 59 --> <!-- /react-text --></span>
</a>

Is this under docsy's scope or is it a bug with swaggerUi ?

I tried to look at the code but didn't find any hint of what could be the problem.

Madril commented 2 years ago

Happens the same with me.

LisaFC commented 2 years ago

Might be a problem with SwaggerUI as I don't remember there being any problems with the integration with Docsy before, but let me look into it. @theletterf if you're around do you want to take a look too?

theletterf commented 2 years ago

OK, I get it now. That's the intended behavior in Swagger UI. See https://petstore.swagger.io/ for example. The URL to the specs appear beneath the title.

Madril commented 2 years ago

There it works @theletterf since the href is set: <a target="_blank" href="https://petstore.swagger.io/v2/swagger.json" rel="noopener noreferrer" class="link"><span class="url"> https://petstore.swagger.io/v2/swagger.json</span></a>

In my case, and I believe in @brunoamaral's as well, href contains about:blank.

theletterf commented 2 years ago

Going to try this on my machine and will let you know.

theletterf commented 2 years ago

I've tested this using https://github.com/google/docsy-example and a sample PetStore OpenAPI 3.0 file from SwaggerHub.

The swaggerui shortcode uses relURL to fetch the file: https://github.com/google/docsy/blob/master/layouts/shortcodes/swaggerui.html

I'd bet this issue has something to do with absURL vs relURL, or with a baseURL issue. Could you have a look at your setup?

chalin commented 1 year ago

Hi @theletterf: is this still an problem?

theletterf commented 1 year ago

@chalin Probably, but would only lead to edits to the docs, I think.