docsy icon indicating copy to clipboard operation
docsy copied to clipboard

broken link on swagger ui

Open brunoamaral opened this issue 2 years ago • 6 comments

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.

brunoamaral avatar Feb 04 '22 17:02 brunoamaral

Happens the same with me.

Madril avatar Feb 04 '22 17:02 Madril

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?

LisaFC avatar Feb 07 '22 17:02 LisaFC

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.

theletterf avatar Feb 07 '22 17:02 theletterf

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.

Madril avatar Feb 07 '22 18:02 Madril

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

theletterf avatar Feb 09 '22 08:02 theletterf

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

  • I've placed the file under content/en/
  • I've used your code in content/en/docs/Examples/_index.md
  • The config.toml file has baseURL set to /

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?

theletterf avatar Feb 09 '22 09:02 theletterf

Hi @theletterf: is this still an problem?

chalin avatar May 04 '23 15:05 chalin

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

theletterf avatar May 05 '23 05:05 theletterf