mirror of
https://github.com/zoriya/elysia-swagger.git
synced 2026-06-03 06:05:35 +00:00
Adding simple working validating test
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
"elysia": ">= 0.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@apidevtools/swagger-parser": "^10.1.0",
|
||||
"@types/node": "^20.1.4",
|
||||
"bun-types": "^0.7.0",
|
||||
"elysia": "0.7.10",
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { Elysia, t } from 'elysia'
|
||||
import SwaggerParser from '@apidevtools/swagger-parser';
|
||||
import { swagger } from '../src'
|
||||
|
||||
import { describe, expect, it } from 'bun:test'
|
||||
import { fail } from 'assert';
|
||||
|
||||
const req = (path: string) => new Request(`http://localhost${path}`)
|
||||
|
||||
@@ -13,6 +15,13 @@ describe('Swagger', () => {
|
||||
expect(res.status).toBe(200)
|
||||
})
|
||||
|
||||
it('returns a valid Swagger/OpenAPI json config', async () => {
|
||||
const app = new Elysia().use(swagger())
|
||||
const res = await app.handle(req('/swagger/json')).then((x) => x.json());
|
||||
expect(res.openapi).toBe("3.0.3");
|
||||
await SwaggerParser.validate(res).catch((err) => fail(err));
|
||||
});
|
||||
|
||||
it('use custom Swagger version', async () => {
|
||||
const app = new Elysia().use(
|
||||
swagger({
|
||||
|
||||
Reference in New Issue
Block a user