Skip to content

Commit

Permalink
Merge branch 'main' into feat-swaggerui-options
Browse files Browse the repository at this point in the history
  • Loading branch information
SaltyAom authored Sep 26, 2023
2 parents b58f637 + 929c08d commit c726674
Show file tree
Hide file tree
Showing 10 changed files with 271 additions and 163 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: 'npm'
directory: './'
schedule:
interval: 'daily'

- package-ecosystem: 'github-actions'
directory: './'
schedule:
interval: 'daily'
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Code CI

on:
push:
pull_request:

jobs:
build:
name: Build and test code
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Install packages
run: bun install

- name: Build code
run: bun run build

- name: Test
run: bun run test
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# 0.7.2 - 21 Sep 2023
Bug fix:
- Paths is undefined
- Models is not showing

# 0.7.1 - 20 Sep 2023
Bug fix:
- Add openapi-types as dependencies
- Fix `any` returned type

# 0.7.0 - 20 Sep 2023
- Add support for Elysia 0.

# 0.7.0-beta.0 - 18 Sep 2023
- Add support for Elysia 0.7

# 0.6.2 - 11 Sep 2023
- Ship lodash.cloneDeep type

Expand Down
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion example/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const app = new Elysia({
documentation: {
info: {
title: 'Elysia',
version: '0.6.10'
version: '0.7.0'
},
tags: [
{
Expand Down
205 changes: 101 additions & 104 deletions example/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,106 +1,103 @@
import { Elysia, t } from 'elysia'

export const plugin = (app: Elysia) =>
app.group(
'/a',
(app) =>
app
.model({
sign: t.Object(
{
username: t.String(),
password: t.String()
},
{
description: 'Models for handling authentication'
}
),
number: t.Number()
})
.get('/', ({ set }) => 'hi', {
detail: {
summary: 'Ping Pong',
description: 'Lorem Ipsum Dolar',
tags: ['Test']
}
})
.get('/unpath/:id', ({ params: { id } }) => id, {
params: t.Object({
id: t.String({
description: 'Extract value from path parameter'
})
}),
detail: {
deprecated: true
}
})
.post('/json', ({ body }) => body, {
type: 'json',
body: 'sign',
response: {
200: 'sign'
},
detail: {
summary: 'Using reference model'
}
})
// .post(
// '/json/:id',
// ({ body, params: { id }, query: { name } }) => ({
// ...body,
// id
// }),
// {
// transform({ params }) {
// params.id = +params.id
// },
// schema: {
// body: 'sign',
// params: t.Object({
// id: t.Number()
// }),
// response: {
// 200: t.Object(
// {
// id: t.Number(),
// username: t.String(),
// password: t.String()
// },
// {
// title: 'User',
// description:
// "Contains user's confidential metadata"
// }
// ),
// 400: t.Object({
// error: t.String()
// })
// },
// detail: {
// summary: 'Transform path parameter'
// }
// }
// }
// )
.post('/file', ({ body: { file } }) => file, {
body: t.Object({
file: t.File({
type: ['image/jpeg', 'image/'],
minSize: '1k',
maxSize: '5m'
})
}),
response: t.File()
})
// .post('/files', ({ body: { files } }) => files[0], {
// schema: {
// body: t.Object({
// files: t.Files({
// type: 'image',
// maxSize: '5m'
// })
// }),
// response: t.File()
// }
// })
)
export const plugin = new Elysia({
prefix: '/a'
})
.model({
sign: t.Object(
{
username: t.String(),
password: t.String()
},
{
description: 'Models for handling authentication'
}
),
number: t.Number()
})
.get('/', ({ set }) => 'hi', {
detail: {
summary: 'Ping Pong',
description: 'Lorem Ipsum Dolar',
tags: ['Test']
}
})
.get('/unpath/:id', ({ params: { id } }) => id, {
params: t.Object({
id: t.String({
description: 'Extract value from path parameter'
})
}),
detail: {
deprecated: true
}
})
.post('/json', ({ body }) => body, {
type: 'json',
body: 'sign',
response: {
200: 'sign'
},
detail: {
summary: 'Using reference model'
}
})
// .post(
// '/json/:id',
// ({ body, params: { id }, query: { name } }) => ({
// ...body,
// id
// }),
// {
// transform({ params }) {
// params.id = +params.id
// },
// schema: {
// body: 'sign',
// params: t.Object({
// id: t.Number()
// }),
// response: {
// 200: t.Object(
// {
// id: t.Number(),
// username: t.String(),
// password: t.String()
// },
// {
// title: 'User',
// description:
// "Contains user's confidential metadata"
// }
// ),
// 400: t.Object({
// error: t.String()
// })
// },
// detail: {
// summary: 'Transform path parameter'
// }
// }
// }
// )
.post('/file', ({ body: { file } }) => file, {
body: t.Object({
file: t.File({
type: ['image/jpeg', 'image/'],
minSize: '1k',
maxSize: '5m'
})
}),
response: t.File()
})
// .post('/files', ({ body: { files } }) => files[0], {
// schema: {
// body: t.Object({
// files: t.Files({
// type: 'image',
// maxSize: '5m'
// })
// }),
// response: t.File()
// }
// })
102 changes: 51 additions & 51 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
{
"name": "@elysiajs/swagger",
"version": "0.6.2",
"description": "Plugin for Elysia to auto-generate Swagger page",
"author": {
"name": "saltyAom",
"url": "https://github.com/SaltyAom",
"email": "saltyaom@gmail.com"
},
"main": "./dist/index.js",
"exports": {
"bun": "./dist/index.js",
"node": "./dist/cjs/index.js",
"require": "./dist/cjs/index.js",
"import": "./dist/index.js",
"default": "./dist/index.js"
},
"types": "./src/index.ts",
"keywords": [
"elysia",
"swagger"
],
"homepage": "https://github.com/elysiajs/elysia-swagger",
"repository": {
"type": "git",
"url": "https://github.com/elysiajs/elysia-swagger"
},
"bugs": "https://github.com/elysiajs/elysia-swagger/issues",
"license": "MIT",
"scripts": {
"dev": "bun run --watch example/index.ts",
"test": "bun test && npm run test:node",
"test:node": "npm install --prefix ./test/node/cjs/ && npm install --prefix ./test/node/esm/ && node ./test/node/cjs/index.js && node ./test/node/esm/index.js",
"build": "rimraf dist && tsc --project tsconfig.esm.json && tsc --project tsconfig.cjs.json",
"release": "npm run build && npm run test && npm publish --access public"
},
"peerDependencies": {
"elysia": ">= 0.6.7"
},
"devDependencies": {
"@types/node": "^20.1.4",
"bun-types": "^0.7.0",
"elysia": "^0.6.20",
"eslint": "^8.40.0",
"rimraf": "4.3",
"typescript": "^5.0.4"
},
"dependencies": {
"@types/lodash.clonedeep": "^4.5.7",
"@types/swagger-ui": "^3.52.0",
"lodash.clonedeep": "^4.5.0"
}
"name": "@elysiajs/swagger",
"version": "0.7.2",
"description": "Plugin for Elysia to auto-generate Swagger page",
"author": {
"name": "saltyAom",
"url": "https://github.com/SaltyAom",
"email": "saltyaom@gmail.com"
},
"main": "./dist/index.js",
"exports": {
"bun": "./dist/index.js",
"node": "./dist/cjs/index.js",
"require": "./dist/cjs/index.js",
"import": "./dist/index.js",
"default": "./dist/index.js"
},
"types": "./src/index.ts",
"keywords": [
"elysia",
"swagger"
],
"homepage": "https://github.com/elysiajs/elysia-swagger",
"repository": {
"type": "git",
"url": "https://github.com/elysiajs/elysia-swagger"
},
"bugs": "https://github.com/elysiajs/elysia-swagger/issues",
"license": "MIT",
"scripts": {
"dev": "bun run --watch example/index.ts",
"test": "bun test && npm run test:node",
"test:node": "npm install --prefix ./test/node/cjs/ && npm install --prefix ./test/node/esm/ && node ./test/node/cjs/index.js && node ./test/node/esm/index.js",
"build": "rimraf dist && tsc --project tsconfig.esm.json && tsc --project tsconfig.cjs.json",
"release": "npm run build && npm run test && npm publish --access public"
},
"peerDependencies": {
"elysia": ">= 0.7.0"
},
"devDependencies": {
"@types/node": "^20.1.4",
"bun-types": "^0.7.0",
"elysia": "0.7.5",
"eslint": "^8.40.0",
"rimraf": "4.3",
"typescript": "^5.0.4"
},
"dependencies": {
"@types/lodash.clonedeep": "^4.5.7",
"lodash.clonedeep": "^4.5.0",
"openapi-types": "^12.1.3"
}
}
Loading

0 comments on commit c726674

Please sign in to comment.