How do I reference a image in my API description so that the image is 
resolved correctly via Swagger UI?

For example:

   
http://www.example.com/swagger-ui/?url=http://www.example.com/apis/v1.0.0/openapi.yaml

I want to include an image in a description in openapi.yaml , referencing a 
image that is relative to the yaml source file, 

  <a href='entities.png' alt='Resource entity relationship diagram'/>

or Markdown

  ![Resource entity relationship diagram](entities.png)

but the browser will try to resolve it relative to the ../swagger-ui 
location, http://www.example.com/swagger-ui/entities.png which of course 
fails. I really want the image (in this case) to be resolved relative to 
the openapi.yaml file, i.e. http://www.example.com/apis/v1.0.0/entities.png

Note that the openapi.yaml source file does *not* know the absolute URI 
where the OpenAPI spec will be deployed (and it fact, in the context of 
this image, it may be in multiple places - .../apis/v1.0.0/ or .../apis/v1.1.0/ 
etc.) and thus we can't hard code the paths to images or other document 
resources. (We do publish our specs via a process, so we can add deployment 
logic to resolve the links then, but that's an extra step). Is there some 
options in swagger-ui to enable relative link rewriting based on the ?url= 
value?

The FAQ <https://github.com/swagger-api/swagger-ui/wiki/FAQ> is noticeably 
sparse and does not offer spec authoring hints.

thanks,
djb

-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to