Closed pratikdevdas closed 1 month ago
Hi @pratikdevdas, have you found a solution yourself?
Yes one could do it modifying there code like this typically using schema generator.
defaults: {
schemasGenerator(service, model, modelName, schemas) {
if (service.options && service.options.Model) {
const modelSchema = app
.get('jsonSchemaManager')
.generate(
service.options.Model,
app.get('openApi3Strategy'),
service.options.Model.options.jsonSchema
);
return {
[model]: modelSchema,
[`${model}_pagination`]: {
title: `${modelName} pagination`,
type: 'array',
items: { $ref: `#/components/schemas/${model}` },
},
[`${model}_list`]: {
title: `${modelName} list`,
type: 'array',
items: { $ref: `#/components/schemas/${model}` },
},
};
}
return {};
},
},
My end goal is to attach schema to my autogenerated swagger route definitions. When I call my swagger middleware before services, I get the route, but my schema is ignored. And when I call my swagger middleware after the services, it says nothing is defined in the specs. According to the docs, I am aware that the swagger initialization should always be done before the services.
The following code generates the schema only when the swagger is defined after services:
usage:
app.configure(services) app.configure(swagger)