System Information
- Strapi Version: 4.3.2
- Operating System: Windows
- Database: MariaDB 10.6.10
- Node Version: 16.13.2
- NPM Version: 8.1.2
- Yarn Version: -
Hello,
I am trying to add documentation for custom endpoints added to api controller generated through admin portal through content-type builder. Endpoints work fine, as expected. But now I am trying to include it in the swagger documentation.
Content type is named ‘app-configuration’;
src/api/app-configuration/routes/custom.ts
export default {
routes: [
{
method: 'GET',
path: '/app-configuration/latest',
handler: 'app-configuration.getLatestPublishedConfigurationAsync',
config: {
auth: false
}
},
{
method: 'GET',
path: '/app-configuration/latest/hash',
handler: 'app-configuration.getLatestPublishedConfigurationHashAsync',
config: {
auth: false
}
}
]
}
src/api/app-configuration/controllers/app-configuration.ts
import { factories } from '@strapi/strapi'
import { getLatestConfigurationAsync, getLatestConfigurationShaAsync } from '../services/latestConfigHandler'
export default factories.createCoreController('api::app-configuration.app-configuration', ({ strapi }) => ({
async getLatestPublishedConfigurationAsync() {
return await getLatestConfigurationAsync(strapi);
},
async getLatestPublishedConfigurationHashAsync() {
return await getLatestConfigurationShaAsync(strapi)
}
}));
I know that this will not work magically, I need to add some json specification by myself. The problem is I don’t know where should it be located and what shape and name the file should have. Of course I tried to extend swagger after reading documentation, but to be honest, it seems incomplete and I don’t understand what should I do to achieve my goal.
Thanks in advance.