mirror of
https://github.com/Unleash/unleash.git
synced 2025-07-17 13:46:47 +02:00
## About the changes Add new methods to simplify the creation of schemas for endpoints with additional media types (other than `application/json`) This is a follow-up on exporting an endpoint as `text/csv`
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import {
|
|
createResponseSchema,
|
|
createResponseSchemas,
|
|
schemaNamed,
|
|
schemaTyped,
|
|
} from './create-response-schema';
|
|
|
|
test('createResponseSchema', () => {
|
|
expect(createResponseSchema('schemaName')).toMatchInlineSnapshot(`
|
|
{
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/schemaName",
|
|
},
|
|
},
|
|
},
|
|
"description": "schemaName",
|
|
}
|
|
`);
|
|
});
|
|
|
|
test('createResponseSchemaWithDifferentMedia', () => {
|
|
expect(
|
|
createResponseSchemas('my-schema', {
|
|
'application/json': schemaNamed('schemaName'),
|
|
'text/css': schemaTyped('string'),
|
|
}),
|
|
).toMatchInlineSnapshot(`
|
|
{
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/schemaName",
|
|
},
|
|
},
|
|
"text/css": {
|
|
"schema": {
|
|
"type": "string",
|
|
},
|
|
},
|
|
},
|
|
"description": "my-schema",
|
|
}
|
|
`);
|
|
});
|