express-jsdoc-swagger
Version:
Swagger OpenAPI 3.x generator
19 lines (15 loc) • 456 B
JavaScript
const getSchema = require('./schema');
const DEFAULT_CONTENT_TYPE = 'application/json';
const getContent = entity => (type, contentType, originalValue, examples, extendSchema = {}) => {
const schema = getSchema(entity, originalValue)(type);
return {
[contentType || DEFAULT_CONTENT_TYPE]: {
schema: {
...schema,
...extendSchema,
},
...(examples ? { examples } : {}),
},
};
};
module.exports = getContent;