Search code examples
htmlyamlopenapi

Is there a way to call an external html code into a yaml file


I am creating a documentation with Redoc in Springboot and i am looking to call sections from html files instead of writing everything in a yaml file

this is the exemple in the yaml file :

tags:
- name: Description
description: |
<p>This is the <strong>Description</strong>of the API.</p>

is there a way to call the paragraph from a html file since sometime it could be long paragraphs and perhabes i could use some design with css.


Solution

  • You might consider using externalDocs property.

    This property allows you to define a url where documentation is hosted for the api.

    openapi: 3.0.3
    info:
      title: my api
      version: 1.0.0
    externalDocs:
      description: a link to my external documentation for this api
      url: https://developer.myapi.com
    servers: []
    paths: {}
    components: {}
    

    Alternatively, you can reference external markdown documents using $ref for descriptions. This can be a nice way to externalize and manage all of your descriptions. This method can be used for any description property throughout the OpenAPI description document.

    openapi: 3.0.3
    info:
      title: my api
      version: 1.0.0
    servers: []
    paths: {}
    components:
      schemas:
        my_schema:
          description:
            $ref: './docs/my_schema_docs.md
    
    docs/my_schema_docs.md
    some text about my api using CommonMark syntax described by OpenAPI
    

    src: CommonMark syntax