unleash-server
Version:
Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.
56 lines • 1.56 kB
JavaScript
export const createResponseSchemas = (description, content) => {
return {
description,
content: content,
};
};
export const schemaNamed = (schemaName) => {
return {
schema: {
$ref: schemaName.startsWith('#')
? schemaName
: `#/components/schemas/${schemaName}`,
},
};
};
export const schemaTyped = (type) => {
return {
schema: {
type,
},
};
};
export const createResponseSchema = (schemaName) => {
return createResponseSchemas(schemaName, {
'application/json': schemaNamed(schemaName),
});
};
export const createCsvResponseSchema = (schemaName, example) => {
return createResponseSchemas(schemaName, {
'text/csv': { example, ...schemaTyped('string') },
});
};
export const resourceCreatedResponseSchema = (schemaName) => {
return {
headers: {
location: {
description: 'The location of the newly created resource.',
schema: {
type: 'string',
format: 'uri',
},
},
},
description: 'The resource was successfully created.',
content: {
'application/json': {
schema: {
$ref: schemaName.startsWith('#')
? schemaName
: `#/components/schemas/${schemaName}`,
},
},
},
};
};
//# sourceMappingURL=create-response-schema.js.map