LoginSignup
0
0

More than 3 years have passed since last update.

CircleCIでswagger-uiをartifactに入れたい

Posted at

概要

できるだけ余計なものを入れずに、Artifact上でスキーマ定義が見えるようにしたい。

やり方

まずschema/swagger.ymlにスキーマ定義がされてるとします。
そしたらschema/index.htmlを作成します。

schema/index.html
<html>
    <head>
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swagger-ui-dist@3.31.1/swagger-ui.css">
        <script src="https://unpkg.com/swagger-ui-dist@3.31.1/swagger-ui-bundle.js"></script>
        <script>
          function render() {
            var ui = SwaggerUIBundle({
              url:  `swagger.yml`,
              dom_id: '#swagger-ui',
              presets: [
                SwaggerUIBundle.presets.apis,
                SwaggerUIBundle.SwaggerUIStandalonePreset
              ]
            });
          }
        </script>
    </head>
    <body onload="render()">
        <div id="swagger-ui"></div>
    </body>
</html>

CircleCIでschema/index.htmlschema/swagger.ymlをArtifactに入れれば完了です。
(ディレクトリのなかにそれしかなければディレクトリごとあげちゃえばOK)

circleci/config.yml
  ...
  store_schema:
    steps:
      - checkout
      - store_artifacts:
          path: schema
  ...

これで余計な依存を作らずにHTMLファイル1つ足すだけで動作させることができます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0