ad-on-is / adonis-autoswagger

Auto-Generate swagger docs for AdonisJS
MIT License
97 stars 32 forks source link

Annotations not Recognized in Controller #80

Closed Kriskev closed 2 months ago

Kriskev commented 2 months ago

Hello,

I am currently using the adonis-autoswagger package to automate the generation of Swagger documentation for my AdonisJS application. However, I've encountered an issue where annotations like @tag, @summary, @description, and other related annotations within the controller are not being recognized or processed by AutoSwagger.

Environment:

AdonisJS Version: 6.2.2 AutoSwagger Version: 3.19.0

Kriskev commented 2 months ago

import UserService from '#services/user_service' import { inject } from '@adonisjs/core' import { HttpContext } from '@adonisjs/core/http' import registerValidator, { registerSchema } from '#validators/auth/register'

@inject() export default class AuthController { constructor(protected userService: UserService) {}

/**

import router from '@adonisjs/core/services/router' const AuthController = () => import('#controllers/auth_controller')

export const frontRoutes = () => { router .group(() => { router.get('/test-swagger', [AuthController, 'testSwagger']) }) .prefix('api') }

/* -------------------------------------------------------------------------- Routes file
The routes file is used for defining the HTTP routes.

*/

import router from '@adonisjs/core/services/router' import AutoSwagger from 'adonis-autoswagger' import swagger from '#config/swagger' import { frontRoutes } from './front_routes.js'

frontRoutes() router.get('/', async () => { return { hello: 'world', } })

// returns swagger in YAML router.get('/swagger', async () => { return AutoSwagger.default.docs(router.toJSON(), swagger) })

// Renders Swagger-UI and passes YAML-output of /swagger router.get('/docs', async () => { return AutoSwagger.default.ui('/swagger', swagger) })

ad-on-is commented 2 months ago

you are missing a @testSwagger (your method name) in your controller.

please read the docs for reference.

Kriskev commented 2 months ago

Thank you for your quick response. I realized that I had indeed missed some important details regarding how to properly use annotations in the controller. I appreciate your guidance in pointing out what was missing and how to correctly implement it. Thank you once again for your support and the great work!