Springfox-动态的swagger模式

时间:2019-04-03 09:44:53

标签: java rest spring-boot swagger-2.0 springfox

我有一个Java SpringBoot应用程序-REST微服务。 Books-subscription-microservice

有多个使用此微服务的客户端(前端,移动,订阅等)。

它返回书本。

let str = fs.readFileSync("data_files/rules.csv", "utf-8");

JSON模式

{
    "title" : "A book",
    "author" : "An author",
    "reviews" : [
        {
            "title" : "Great Book"
            "author" : "Reader - John"
            "content" : "Oh, such a good book, and it makes me feel so good"
        }
    ]
}

摇摇欲坠的模式

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "$id": "http://example.com/book.schema.json",
    "title": "Book",
    "description": "A book from books-subscription-microservice",
    "type": "object",
    "properties": {
        "title": {
            "description": "The unique title for a book",
            "type": "string"
        },
        "author": {
            "description": "author of the book",
            "type": "string"
        },
        "reviews": {
            "description": "Reviews of other people about the book",
            "type": "array",
            "items": {
                "$ref": "https://example.com/book-review.schema.json"
            },
            "minItems": 1,
        }
    },
    "required": [ "title", "author" ]
}

待办事项更新问题,添加我现在如何生成摇摇欲坠的模式

如何动态返回摇摇欲坠的架构?例如,对于高级客户,我将退还完整书,对于社区客户,我将退还未审查的书?以及相应的摇摇欲坠的模式?

0 个答案:

没有答案