Gathering detailed insights and metrics for @suin/esa-openapi
Gathering detailed insights and metrics for @suin/esa-openapi
npm install @suin/esa-openapi
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (99.09%)
HTML (0.82%)
Shell (0.1%)
Total Downloads
2,191
Last Day
2
Last Week
9
Last Month
35
Last Year
185
6 Stars
27 Commits
1 Forks
2 Watching
1 Branches
3 Contributors
Latest Version
2.2.0
Package Id
@suin/esa-openapi@2.2.0
Unpacked Size
107.14 kB
Size
15.26 kB
File Count
5
NPM Version
6.14.16
Node Version
14.19.0
Cumulative downloads
Total Downloads
Last day
0%
2
Compared to previous day
Last week
0%
9
Compared to previous week
Last month
337.5%
35
Compared to previous month
Last year
-70.8%
185
Compared to previous year
esa.io API v1 を OpenAPI 規格に基づいて定義したものです。
OpenAPI 定義ファイルはesa-api.jsonになります。
Swagger Editor は、ブラウザ上で OpenAPI を編集したり、API ドキュメントをプレビューが見れるエディタです。
Swagger Editor で esa API を読み込むには次の手順を行ってください:
メニューの「File」→「Import URL」でダイアログを開き、次の URL を入力する:
https://raw.githubusercontent.com/suin/esa-openapi/main/esa-api.json
エディタのプレビュー画面上では、認証情報を入力することで、実際の API にリクエストを送信することもできます。認証情報はプレビュー画面右上の「Authorize」を開き、「AccessTokenHeader」に本物の esa API アクセストークンを入力してください。(OAuth2 による認証方法はうまく動きません。)
ReDoc は OpenAPI のファイルを読み込むだけで API ドキュメントを表示できる React ベースのウェブアプリケーションです。
OpenAPI Generator は様々な言語の API クライアントを生成できるツールです。
OpenAPI Generator は次の複数の方法でインストールできます。
詳細は公式ドキュメントをご覧ください。
ここでは NPM でインストールした OpenAPI Generator を用いてクライアントを生成する方法を説明します。
TypeScript のクライアントを生成するには次のコマンドを実行します:
1npx @openapitools/openapi-generator-cli generate \ 2 -g typescript-axios \ 3 -i https://raw.githubusercontent.com/suin/esa-openapi/main/esa-api.json \ 4 -o client \ 5 --additional-properties=supportsES6=true,typescriptThreePlus=true,useSingleRequestParameter=true,withSeparateModelsAndApi=true,apiPackage=api,modelPackage=models
クライアントはclient
ディレクトリに生成されます。これを TypeScript で使うには次のようにします:
1import { Configuration, EsaApi } from "./client"; 2 3(async () => { 4 const esaApi = new EsaApi( 5 new Configuration({ accessToken: process.env.ESA_API_TOKEN }) 6 ); 7 const { data } = await esaApi.getPosts({ teamName: "doc" }); 8 9 for (const post of data.posts) { 10 console.log(post.name); 11 } 12})();
TypeScript は typescript-axios の他にも次のクライアントが生成できます:
Guzzle を用いた PHP クライアントライブラリが生成できます。
PHP のクライアントを生成するには次のコマンドを実行します:
1npx @openapitools/openapi-generator-cli generate \ 2 -g php \ 3 -i https://raw.githubusercontent.com/suin/esa-openapi/main/esa-api.json \ 4 -o client \ 5 --additional-properties=invokerPackage='YourOrg\YourProject'
esa-api.json は NPM パッケージとして配布しています。npm でインストールすると JavaScript 上で読み込めます。
インストール方法:
1npm install @suin/esa-openapi
Node.js で読み込む方法:
1const esaOpenApi = require("@suin/esa-openapi"); 2 3console.log(esaOpenApi); 4//=> { 5// openapi: '3.0.0', 6// info: { 7// title: 'esa API v1', 8// description: 'チームのナレッジ共有サービス[esa.io](https://esa.io/)のAPI v1の仕様書', 9// version: '1.0.0', 10// termsOfService: 'https://docs.esa.io/posts/5', 11// 'x-logo': { 12// url: 'https://img.esa.io/uploads/production/attachments/3/2018/11/13/2/fe8f24a1-a23d-4c96-951c-f6f4433d1399.png', 13// altText: 'esa' 14// } 15// }, 16// ...
このプロジェクトの開発に参加する方法について説明します。
パッケージマネージャーは PNPM をお使い下さい。
このプロジェクトをクローンしたら次のコマンドでパッケージをインストールします:
1pnpm install
esa API はそれなりの規模になるため、OpenAPI のファイルひとつとして管理するのが難しいです。そこで、このプロジェクトでは esa API を TypeScript で記述し、プログラムによって esa-api.json を生成するアプローチをとっています。
esa API の記述は複数の TypeScript ファイルに分割しています。これらファイルの構造は主に次の通りになっています。
esa-api.json を生成するには次のコマンドを実行してください:
1pnpm generate:spec
esa-api.json をバリデーションするには次のコマンドを実行してください:
1pnpm validate:spec
※実行には Java8 が必要です。
クライアントライブラリを生成するには次のコマンドを実行してください:
1pnpm generate:client
※実行には Java8 が必要です。
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 1/27 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
40 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More