yangbo / swagger-grails4

A Grails-v4 Plugin to automatically generate REST API document using OpenAPI-v3 (swagger)
MIT License
12 stars 5 forks source link

Endpoint does not appear correctly. #32

Open CassioFerreiraRod opened 3 months ago

CassioFerreiraRod commented 3 months ago

Hello, our endpoints that have parameters are not being recognized by the plugin. ex My controller: @ApiDoc(tag = { description "Test API" }) class TesteController { static responseFormats = ['json', 'xml']

@ApiDoc(operation = {
    summary "Test"
    description "Teste de swagger"
    parameters([{
                    name "s"
                    description "Texto qualquer"
                    inType "path"
                    schema { "string" }
                }])
    responses "200": {
        content "application/json": {
            description "success response"
            schema {
                name "Resposta"
                type "string"
                description "Texto digitado"
            }
        }
    }
})
def teste(String s) {
    render([text: s]as JSON)
}

}

My url mappings: class UrlMappings {

static mappings = {
    delete "/$controller/$id(.$format)?"(action: "delete")
    get "/$controller(.$format)?"(action: "index")
    get "/$controller/$id(.$format)?"(action: "show")
    post "/$controller(.$format)?"(action: "save")
    put "/$controller/$id(.$format)?"(action: "update")
    patch "/$controller/$id(.$format)?"(action: "patch")

    get "/test/$s"(controller: "teste", action: "teste")

    "500"(view: '/error')
    "404"(view: '/notFound')
}

}

yangbo commented 3 months ago

Hi, thanks for report, I have tried to reproduce the issue but have not your issue.

Maybe you can try these:

  1. reboot your app and see if the issue resolved.
  2. change the typo of
    @apidoc(tag = {
    description "Test API"
    })
    class TesteController

    to

    @Apidoc(tag = {
    description "Test API"
    })
    class TesteController
  3. You can move your controller and url-mapping to 'swagger-grails4-samples' project and see if there is the issue.

Good luck!