mirror of
https://github.com/zoriya/elysia-swagger.git
synced 2025-12-19 22:35:11 +00:00
Fixing failing test
This commit is contained in:
@@ -136,7 +136,7 @@ export const swagger =
|
|||||||
method: route.method,
|
method: route.method,
|
||||||
path: route.path,
|
path: route.path,
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
models: app.definitions.type,
|
models: app.definitions?.type,
|
||||||
contentType: route.hooks.type
|
contentType: route.hooks.type
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -161,7 +161,7 @@ export const swagger =
|
|||||||
...documentation.components,
|
...documentation.components,
|
||||||
schemas: {
|
schemas: {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
...app.definitions.type,
|
...app.definitions?.type,
|
||||||
...documentation.components?.schemas
|
...documentation.components?.schemas
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
20
src/utils.ts
20
src/utils.ts
@@ -22,16 +22,18 @@ export const mapProperties = (
|
|||||||
if (schema in models) schema = models[schema]
|
if (schema in models) schema = models[schema]
|
||||||
else throw new Error(`Can't find model ${schema}`)
|
else throw new Error(`Can't find model ${schema}`)
|
||||||
|
|
||||||
return Object.entries(schema?.properties ?? []).map(([key, value]) => ({
|
return Object.entries(schema?.properties ?? []).map(([key, value]) => {
|
||||||
|
const { type: valueType = undefined, ...rest } = value as any;
|
||||||
|
return {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
...value,
|
...rest,
|
||||||
|
schema: { type: valueType },
|
||||||
in: name,
|
in: name,
|
||||||
name: key,
|
name: key,
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
type: value?.type,
|
required: schema!.required?.includes(key) ?? false,
|
||||||
// @ts-ignore
|
};
|
||||||
required: schema!.required?.includes(key) ?? false
|
});
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapTypesResponse = (
|
const mapTypesResponse = (
|
||||||
@@ -118,7 +120,7 @@ export const registerSchemaPath = ({
|
|||||||
|
|
||||||
if (typeof responseSchema === 'object') {
|
if (typeof responseSchema === 'object') {
|
||||||
if (Kind in responseSchema) {
|
if (Kind in responseSchema) {
|
||||||
const { type, properties, required, ...rest } =
|
const { type, properties, required, additionalProperties, ...rest } =
|
||||||
responseSchema as typeof responseSchema & {
|
responseSchema as typeof responseSchema & {
|
||||||
type: string
|
type: string
|
||||||
properties: Object
|
properties: Object
|
||||||
@@ -162,7 +164,7 @@ export const registerSchemaPath = ({
|
|||||||
content: mapTypesResponse(contentTypes, value)
|
content: mapTypesResponse(contentTypes, value)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const { type, properties, required, ...rest } =
|
const { type, properties, required, additionalProperties, ...rest } =
|
||||||
value as typeof value & {
|
value as typeof value & {
|
||||||
type: string
|
type: string
|
||||||
properties: Object
|
properties: Object
|
||||||
@@ -286,7 +288,7 @@ export const filterPaths = (
|
|||||||
.map((x) => ({
|
.map((x) => ({
|
||||||
in: 'path',
|
in: 'path',
|
||||||
name: x.slice(1, x.length - 1),
|
name: x.slice(1, x.length - 1),
|
||||||
type: 'string',
|
schema: { type: "string" },
|
||||||
required: true
|
required: true
|
||||||
})),
|
})),
|
||||||
...schema.parameters
|
...schema.parameters
|
||||||
|
|||||||
Reference in New Issue
Block a user