🎨: Add openapi. (#32)

Signed-off-by: zhanghengxin <812718649@qq.com>
This commit is contained in:
zhanghengxin 2023-03-16 02:07:38 +08:00 committed by GitHub
parent ac34a1356d
commit f5fcd9ed92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 130 additions and 1 deletions

38
.github/workflows/publish_npm.yml vendored Normal file
View File

@ -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}}

7
.gitignore vendored
View File

@ -19,4 +19,9 @@
target/
dist/
__debug_bin
codegen/
codegen/
node_modules/
dist/
.idea
.package-lock.json

View File

@ -3,3 +3,28 @@
[![Go Reference](https://pkg.go.dev/badge/github.com/IceWhaleTech/CasaOS-UserService.svg)](https://pkg.go.dev/github.com/IceWhaleTech/CasaOS-UserService) [![Go Report Card](https://goreportcard.com/badge/github.com/IceWhaleTech/CasaOS-UserService)](https://goreportcard.com/report/github.com/IceWhaleTech/CasaOS-UserService) [![goreleaser](https://github.com/IceWhaleTech/CasaOS-UserService/actions/workflows/release.yml/badge.svg)](https://github.com/IceWhaleTech/CasaOS-UserService/actions/workflows/release.yml) [![codecov](https://codecov.io/gh/IceWhaleTech/CasaOS-UserService/branch/main/graph/badge.svg?token=4GWJIF6FDD)](https://codecov.io/gh/IceWhaleTech/CasaOS-UserService)
User Service provides user management functionalities to CasaOS.
## 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
package.json Normal file
View File

@ -0,0 +1,36 @@
{
"name": "casaos-userservice-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/user-service/openapi.yaml -o ./generate",
"generate:npx": "npx @openapitools/openapi-generator-cli generate -g typescript-axios -i ./api/user-service/openapi.yaml -o ./generate",
"generate:ts": "npx openapi-typescript-codegen --input ./api/user-service/openapi.yaml --output ./generate",
"publish": "npm publish --access public",
"start": "yarn generate:ts && yarn build"
},
"homepage": "https://github.com/IceWhaleTech/CasaOS-UserService#readme",
"description": "Casaos-Localstorage Typescript+Axios SDK",
"keywords": [
"CasaOS-UserService",
"SDK",
"CasaOS-UserService 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
tsconfig.json Normal file
View File

@ -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"
}