mirror of
https://github.com/Unleash/unleash.git
synced 2024-10-18 20:09:08 +02:00
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
|
import {
|
||
|
createOpenApiSchema,
|
||
|
createRequestSchema,
|
||
|
createResponseSchema,
|
||
|
removeJsonSchemaProps,
|
||
|
} from './index';
|
||
|
|
||
|
test('createRequestSchema', () => {
|
||
|
expect(createRequestSchema('schemaName')).toMatchInlineSnapshot(`
|
||
|
Object {
|
||
|
"content": Object {
|
||
|
"application/json": Object {
|
||
|
"schema": Object {
|
||
|
"$ref": "#/components/schemas/schemaName",
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
"description": "schemaName",
|
||
|
"required": true,
|
||
|
}
|
||
|
`);
|
||
|
});
|
||
|
|
||
|
test('createResponseSchema', () => {
|
||
|
expect(createResponseSchema('schemaName')).toMatchInlineSnapshot(`
|
||
|
Object {
|
||
|
"content": Object {
|
||
|
"application/json": Object {
|
||
|
"schema": Object {
|
||
|
"$ref": "#/components/schemas/schemaName",
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
"description": "schemaName",
|
||
|
}
|
||
|
`);
|
||
|
});
|
||
|
|
||
|
test('removeJsonSchemaProps', () => {
|
||
|
expect(removeJsonSchemaProps({ a: 'b', $id: 'c', components: {} }))
|
||
|
.toMatchInlineSnapshot(`
|
||
|
Object {
|
||
|
"a": "b",
|
||
|
}
|
||
|
`);
|
||
|
});
|
||
|
|
||
|
test('createOpenApiSchema url', () => {
|
||
|
expect(createOpenApiSchema('https://example.com').servers[0].url).toEqual(
|
||
|
'https://example.com',
|
||
|
);
|
||
|
});
|