Skip to content

Commit

Permalink
chore: API定義をtypespecに置き換える
Browse files Browse the repository at this point in the history
  • Loading branch information
rito528 committed Jun 14, 2024
1 parent 5f16669 commit dbd4e30
Show file tree
Hide file tree
Showing 33 changed files with 1,446 additions and 1,168 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/compile-typespec-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: typespec-compile-and-deploy-gh-pages
on:
push:
branches:
- main

jobs:
compile:
runs-on: ubuntu-22.04
steps:
- name: checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install typespec
run: npm install -g @typespec/compiler

- name: Cache npm modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install node_modules
run: npm ci

- name: Compile typespec
run: tsp compile .

- name: Install redocly-cli
uses: ./.github/actions/install-redocly-cli

- name: Build docs
run: redocly build-docs tsp-output/@typespec/openapi3/openapi.yaml -o ./docs/index.html -t ./.github/template.hbs

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./docs

deploy-github-pages:
needs: compile
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-22.04
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
55 changes: 29 additions & 26 deletions .github/workflows/lint-openapi.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
name: Lint OpenAPI
name: Lint Typespec OpenAPI Definitions
on:
pull_request:
branches:
- main
workflow_call:
push:

jobs:
lint-definitions:
name: Lint OpenAPI definitions
runs-on: ubuntu-latest
check-format:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Install redocly-cli
uses: ./.github/actions/install-redocly-cli
- name: Lint OpenAPI yml
run: redocly lint ./schema/openapi.yml
lint-examples:
name: Lint OpenAPI examples
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install redocly-cli
uses: ./.github/actions/install-redocly-cli
- name: Bundle OpenAPI yml
run: redocly bundle ./schema/openapi.yml -o ./bundled-openapi.yml
- name: Install openapi-examples-validator
run: npm install -g openapi-examples-validator
- name: Lint examples
run: openapi-examples-validator ./bundled-openapi.yml
- name: checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install typespec
run: npm install -g @typespec/compiler

- name: Cache npm modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install node_modules
run: npm ci

- name: Check format
run: tsp format --check "**/*.tsp"
43 changes: 0 additions & 43 deletions .github/workflows/pub-docs.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea
docs
node_modules
**/tsp-output
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ENV PORT=8080

EXPOSE 8080

RUN npm install -g @redocly/cli http-server
RUN npm install -g @typespec/compiler @redocly/cli http-server

USER node
WORKDIR /tmp/files
Expand Down
4 changes: 3 additions & 1 deletion docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash

redocly build-docs /schema/openapi.yml -o ./docs/index.html -t ./template.hbs
tsp compile .

redocly build-docs ./tsp-output/@typespec/openapi3/openapi.yaml -o ./docs/index.html -t ./template.hbs
http-server ./docs -p $PORT
Loading

0 comments on commit dbd4e30

Please sign in to comment.