1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-07-17 13:46:47 +02:00
unleash.unleash/src/lib/openapi/util/create-response-schema.test.ts
Gastón Fournier e325704a0b
chore: support for additional media (#3247)
## 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`
2023-03-06 12:44:12 +01:00

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",
}
`);
});