parent
5403955ef6
commit
a03e133d42
|
@ -26,7 +26,9 @@
|
|||
"build:oauth-providers": "yarn workspace @hono/oauth-providers build",
|
||||
"build": "run-p 'build:*'",
|
||||
"lint": "eslint 'packages/**/*.{ts,tsx}'",
|
||||
"lint:fix": "eslint --fix 'packages/**/*.{ts,tsx}'"
|
||||
"lint:fix": "eslint --fix 'packages/**/*.{ts,tsx}'",
|
||||
"format": "prettier --check 'packages/**/*.{ts,tsx}'",
|
||||
"format:fix": "prettier --write 'packages/**/*.{ts,tsx}'"
|
||||
},
|
||||
"license": "MIT",
|
||||
"private": true,
|
||||
|
|
|
@ -44,7 +44,9 @@ export function githubAuth(options: {
|
|||
// OAuth apps can't have multiple callback URLs, but GitHub Apps can.
|
||||
// As such, we want to make sure we call back to the same location
|
||||
// for GitHub apps and not the first configured callbackURL in the app config.
|
||||
return c.redirect(auth.redirect().concat(options.oauthApp ? '' : `&redirect_uri=${c.req.url}`))
|
||||
return c.redirect(
|
||||
auth.redirect().concat(options.oauthApp ? '' : `&redirect_uri=${c.req.url}`)
|
||||
)
|
||||
}
|
||||
|
||||
// Retrieve user data from github
|
||||
|
|
|
@ -6,7 +6,7 @@ describe('SwaggerUIOption Rendering', () => {
|
|||
renderSwaggerUIOptions({
|
||||
configUrl: 'https://petstore3.swagger.io/api/v3/openapi.json',
|
||||
})
|
||||
).toEqual('configUrl: \'https://petstore3.swagger.io/api/v3/openapi.json\'')
|
||||
).toEqual("configUrl: 'https://petstore3.swagger.io/api/v3/openapi.json'")
|
||||
})
|
||||
|
||||
it('renders correctly with presets', () => {
|
||||
|
@ -59,7 +59,7 @@ describe('SwaggerUIOption Rendering', () => {
|
|||
renderSwaggerUIOptions({
|
||||
url: 'https://petstore3.swagger.io/api/v3/openapi.json',
|
||||
})
|
||||
).toEqual('url: \'https://petstore3.swagger.io/api/v3/openapi.json\'')
|
||||
).toEqual("url: 'https://petstore3.swagger.io/api/v3/openapi.json'")
|
||||
})
|
||||
|
||||
it('renders correctly with urls', () => {
|
||||
|
@ -82,7 +82,7 @@ describe('SwaggerUIOption Rendering', () => {
|
|||
renderSwaggerUIOptions({
|
||||
layout: 'StandaloneLayout',
|
||||
})
|
||||
).toEqual('layout: \'StandaloneLayout\'')
|
||||
).toEqual("layout: 'StandaloneLayout'")
|
||||
})
|
||||
|
||||
it('renders correctly with docExpansion', () => {
|
||||
|
@ -90,7 +90,7 @@ describe('SwaggerUIOption Rendering', () => {
|
|||
renderSwaggerUIOptions({
|
||||
docExpansion: 'list',
|
||||
})
|
||||
).toEqual('docExpansion: \'list\'')
|
||||
).toEqual("docExpansion: 'list'")
|
||||
})
|
||||
|
||||
it('renders correctly with maxDisplayedTags', () => {
|
||||
|
|
|
@ -75,28 +75,36 @@ describe('Types', () => {
|
|||
|
||||
describe('Input types', () => {
|
||||
const ParamsSchema = z.object({
|
||||
id: z.string().transform(Number).openapi({
|
||||
param: {
|
||||
name: 'id',
|
||||
in: 'path',
|
||||
},
|
||||
example: 123,
|
||||
}),
|
||||
id: z
|
||||
.string()
|
||||
.transform(Number)
|
||||
.openapi({
|
||||
param: {
|
||||
name: 'id',
|
||||
in: 'path',
|
||||
},
|
||||
example: 123,
|
||||
}),
|
||||
})
|
||||
|
||||
const QuerySchema = z.object({
|
||||
age: z.string().transform(Number).openapi({
|
||||
param: {
|
||||
name: 'age',
|
||||
in: 'query',
|
||||
},
|
||||
example: 42
|
||||
}),
|
||||
age: z
|
||||
.string()
|
||||
.transform(Number)
|
||||
.openapi({
|
||||
param: {
|
||||
name: 'age',
|
||||
in: 'query',
|
||||
},
|
||||
example: 42,
|
||||
}),
|
||||
})
|
||||
|
||||
const BodySchema = z.object({
|
||||
sex: z.enum(['male', 'female']).openapi({})
|
||||
}).openapi('User')
|
||||
const BodySchema = z
|
||||
.object({
|
||||
sex: z.enum(['male', 'female']).openapi({}),
|
||||
})
|
||||
.openapi('User')
|
||||
|
||||
const UserSchema = z
|
||||
.object({
|
||||
|
@ -111,7 +119,7 @@ describe('Input types', () => {
|
|||
}),
|
||||
sex: z.enum(['male', 'female']).openapi({
|
||||
example: 'male',
|
||||
})
|
||||
}),
|
||||
})
|
||||
.openapi('User')
|
||||
|
||||
|
@ -141,7 +149,6 @@ describe('Input types', () => {
|
|||
},
|
||||
})
|
||||
|
||||
|
||||
it('Should return correct types', () => {
|
||||
const app = new OpenAPIHono()
|
||||
|
||||
|
|
|
@ -17,15 +17,11 @@ export const zValidator = <
|
|||
I = z.input<T>,
|
||||
O = z.output<T>,
|
||||
V extends {
|
||||
in: HasUndefined<I> extends true
|
||||
? { [K in Target]?: I }
|
||||
: { [K in Target]: I };
|
||||
out: { [K in Target]: O };
|
||||
in: HasUndefined<I> extends true ? { [K in Target]?: I } : { [K in Target]: I }
|
||||
out: { [K in Target]: O }
|
||||
} = {
|
||||
in: HasUndefined<I> extends true
|
||||
? { [K in Target]?: I }
|
||||
: { [K in Target]: I };
|
||||
out: { [K in Target]: O };
|
||||
in: HasUndefined<I> extends true ? { [K in Target]?: I } : { [K in Target]: I }
|
||||
out: { [K in Target]: O }
|
||||
}
|
||||
>(
|
||||
target: Target,
|
||||
|
|
Loading…
Reference in New Issue