Giter Site home page Giter Site logo

swagger-github-pages's Introduction

How to host Swagger API documentation with GitHub Pages

The blog of Peter Evans: How to Host Swagger Documentation With Github Pages

This repository is a template for using the Swagger UI to dynamically generate beautiful documentation for your API and host it for free with GitHub Pages.

The template will periodically auto-update the Swagger UI dependency and create a pull request. See the GitHub Actions workflow here.

The example API specification used by this repository can be seen hosted at https://peter-evans.github.io/swagger-github-pages.

Steps to use this template

  1. Click the Use this template button above to create a new repository from this template.

  2. Go to the settings for your repository at https://github.com/{github-username}/{repository-name}/settings and enable GitHub Pages.

    Headers

  3. Browse to the Swagger documentation at https://{github-username}.github.io/{repository-name}/.

Steps to manually configure in your own repository

  1. Download the latest stable release of the Swagger UI here.

  2. Extract the contents and copy the "dist" directory to the root of your repository.

  3. Move the file "index.html" from the directory "dist" to the root of your repository.

    mv dist/index.html .
    
  4. Copy the YAML specification file for your API to the root of your repository.

  5. Edit dist/swagger-initializer.js and change the url property to reference your local YAML file.

        window.ui = SwaggerUIBundle({
            url: "swagger.yaml",
        ...

    Then fix any references to files in the "dist" directory.

    ...
    <link rel="stylesheet" type="text/css" href="dist/swagger-ui.css" >
    <link rel="icon" type="image/png" href="dist/favicon-32x32.png" sizes="32x32" />
    <link rel="icon" type="image/png" href="dist/favicon-16x16.png" sizes="16x16" />    
    ...
    <script src="dist/swagger-ui-bundle.js"> </script>
    <script src="dist/swagger-ui-standalone-preset.js"> </script>    
    ...
  6. Go to the settings for your repository at https://github.com/{github-username}/{repository-name}/settings and enable GitHub Pages.

    Headers

  7. Browse to the Swagger documentation at https://{github-username}.github.io/{repository-name}/.

    The example API specification used by this repository can be seen hosted at https://peter-evans.github.io/swagger-github-pages.

swagger-github-pages's People

Contributors

cclauss avatar dependabot[bot] avatar github-actions[bot] avatar jvilders avatar mbehlendorf avatar peter-evans avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

swagger-github-pages's Issues

Remote swagger file?

Does this repo support pulling an openApi file from a hosted URL, rather than a local file? If not, could it?

In case it helps, my use case is that I have an existing private repo with an auto-generated openApi.yml file. I'd LOVE to add a swagger ui github page to it, but making the repo public isn't an option. I'm working around it right now via scripting by copying over the file contents into the public swagger-ui repo, but it would be much easier if I were able to host the API spec outside the repo and point to it :)

Swagger config file

Is it possible to add swagger config file (swagger-config.json)?

I have tried adding swagger-config.json to the root, as well as the dist/ but SwaggerUIBandle doesn't find it. Or atleast it doesn't change anything.

I need this to specify operationsSorter parameter of the SwaggerUI

Swagger UI GitHub Action

I created a Swagger UI GitHub Action which can be used to automatically generate the Swagger UI static html files based on a spec file and a swagger-config file. The generated Swagger UI is customizable via GitHub Actions inputs and the output can be deployed to GitHub Pages. The Action can be used in the same repository as the REST API service itself and be automatically updated with generated spec files with every push to the git repository.

I used this repository as inspiration to build the Action and how to download and generate the files of the swagger ui. I just wanted to add this here as an alternative to setting up this template repository and customizing swagger ui by hand.

License seems to be missing

Hi @peter-evans ,

thank you for this nice template!

Would you mind adding a LICENSE file?
That would help adoption in certain cases.
In case there is a license mentioned and I've not seen it, I apologize and am happy to take any hint as where to find it.

Thank you,
Ole

Load external in api specs

Hi,
Your repo is so great. I'm following your guide lines to setup my repo. And i found an issue when using external refs in api spec yaml file. It's look like the swagger-ui cannot load the external files, maybe it because of hosting deployment.
I defined external refs in examples of request

            examples:
               response:
                 externalValue: ./token_balances/_TokenBalancesResponse.json
      

Can you give some recommendation for finding solution for this issue

image

Changing the logo

Really enjoying using this project, massive help.

I was wondering if you could help in how to change the default logo on the page.

Screenshot 2023-07-21 at 11 59 51

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.