簡體   English   中英

Grails 3-迅速地記錄Spring Security Rest的登錄API

[英]Grails 3 - documenting spring security rest's login api in swagger

我正在使用帶有服務Spring Security REST和Swagger文檔的Grails 3開發演示REST演示。 以下是Spring Security Rest的依賴項

org.grails.plugins:spring-security-rest:2.0.0.M2

org.grails.plugins:spring-security-rest-gorm:2.0.0.M2

用戶必須登錄才能執行某些操作子集。 使用以下插件添加Swagger Doc並配置為訪問所有公開的API之后,我可以使用“ localhost:// applicationPath / api”訪問所有API的Swagger Doc

org.grails.plugins:swaggydoc-grails3:0.28.0

不幸的是,我沒有列出其中的登錄端點。 如果我將我的LoginController和apis端點控制器一起添加,則它將列出所有登錄api,但是訪問URL變為

應用URL / api / v1 / api / login

哪個效果不好。

問題在於,該部分操作無法通過Swagger UI內置表單執行(我發現它確實不錯,並且希望它能夠正常運行),因為用戶尚未登錄。對此問題有任何解決方案嗎? 我可以在Swagger中手動定義一些端點嗎?

這是我用Swagger注冊任何API的示例代碼

@Api(
        value = 'Sample',
        description = 'Sample APIs.',
        position = 0,
        produces = 'application/json',
        consumes = 'application/json',
        basePath = 'v1',
        protocols = 'http, https',
        hidden = false
)
@Controller()
class SampleController {
@ApiOperation(
            value = 'Sample API',
            notes = '',
            response = Sample,
            responseContainer = 'Array',
            position = 0,
            httpMethod = 'GET',
            produces = 'application/json',
            consumes = 'application/json',
            protocols = 'http, https',
            hidden = false
    )
    @ApiImplicitParams([
            @ApiImplicitParam(name = 'max', value = 'Max records to return', defaultValue = '10', paramType = 'query', dataType = 'int', required = false, allowMultiple = false)
    ])
    @ApiResponses([
            @ApiResponse(code = 200, message = "", response = Sample),
    ])
    def sampleAPI() {
    }
}

如果有人可以提供幫助,那將是很大的幫助。

我創建了一個API,該API調用“ api / login”進行身份驗證

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM