Skip to content

Commit

Permalink
✨: Add openapi. (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghengxin authored Mar 15, 2023
1 parent 953af21 commit fa59a10
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/publish_npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: publish npm

on:
push:
tags:
- v*.*.*
workflow_dispatch:

permissions:
contents: write

jobs:
publish-npm:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- name: Get version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: Set version
run: |
apt install jq
jq '.version="${{ steps.get_version.outputs.VERSION }}"' package.json > package.json.new
mv package.json.new package.json
- name: Generate SDK
run: |
npm cache clean --force
npm install @openapitools/openapi-generator-cli -g
make build
- run: npm i
- run: npm run start
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ dist/
target/
codegen/
__debug_bin

node_modules/
dist/
.idea
.package-lock.json
8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,29 @@
Message bus accepts events and actions from various sources and delivers them to subscribers.

See [openapi.yaml](./api/message_bus/openapi.yaml) for API specification.




## publish api to npm

### edit version in package.json

### run
```bash
yarn

yarn start
```

### publish

Manual publish
```bash
yarn publish
```

Auto publish
```bash
git push origin dev**
```
36 changes: 36 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "casaos-messagebus-openapi",
"version": "0.0.1",
"scripts": {
"build": "rm -rf dist && tsc && rm -rf generate",
"generate:local": "openapi-generator-cli generate -g typescript-axios -i ./api/message_bus/openapi.yaml -o ./generate",
"generate:npx": "npx @openapitools/openapi-generator-cli generate -g typescript-axios -i ./api/message_bus/openapi.yaml -o ./generate",
"generate:ts": "npx openapi-typescript-codegen --input ./api/message_bus/openapi.yaml --output ./generate",
"publish": "npm publish --access public",
"start": "yarn generate:ts && yarn build"
},
"homepage": "https://github.com/IceWhaleTech/CasaOS-MessageBus#readme",
"description": "Casaos-MessageBus Typescript+Axios SDK",
"keywords": [
"CasaOS-MessageBus",
"SDK",
"CasaOS-MessageBus Axios"
],
"main": "dist/index",
"files": [
"LICENSE",
"README.md",
"dist"
],
"dependencies": {
"axios": "^1.1.0"
},
"devDependencies": {
"@openapitools/openapi-generator-cli": "2.5.2",
"@types/node": "^18.8.3",
"openapi-typescript-codegen": "^0.23.0",
"typescript": "^4.9.5"
},
"author": "casaos",
"license": "Apache-2.0"
}
25 changes: 25 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"declaration": true,
"lib": [
"es2017",
"DOM"
],
"module": "commonjs",
"target": "es6",
"skipLibCheck": true,
"sourceMap": false,
"strict": true,
"useUnknownInCatchVariables": false,
"resolveJsonModule": true,
"esModuleInterop": true,
"outDir": "dist",
"types": [
"node"
],
},
"exclude": [
"node_modules"
],
"main": "generate/index"
}

0 comments on commit fa59a10

Please sign in to comment.