如何将 Springdoc Swagger UI 指向我自己的 YAML 文件而不是自动生成的文件?

2024-03-22

我创建了一个 Spring Boot RESTFul 微服务,对于文档,我创建了一个 swagger.yaml 文件,但我不知道如何运行该文件。为了创建 swagger.yaml 文件,我使用了 OpenAPI 规范。我知道我们有一个 Swagger UI 功能可以使用,但我想运行我自己创建的 swagger.yaml 文件,只是为了摆脱大量注释。

openapi: 3.0.1

info:
title: Static Data Manager
description: This is Static data Manager Swagger
version: 1.0.0

servers:
- url: http://localhost:8184/
  description: Generated server url

tags:
- name: LookupController
  description: API of Lookups
- name: LookupDataController
  description: API of Lookups Data
- name: LookupLangController
  description: API of Lookups Lang
- name: TranslationController
  description: API of Translations

paths:
/translation:
get:
  tags:
    - TranslationController
  operationId: fetchAll
  summary: Get All Translations
  parameters:
    - name: text
      in: query
      required: false
      schema:
        type: string
    - name: code
      in: query
      required: false
      schema:
        type: string
    - name: lang
      in: query
      required: false
      schema:
        type: string
    - name: pageable
      in: query
      required: true
      schema:
        $ref: '#/components/schemas/Pageable'
  responses:
    "200":
      description: OK
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/PageTranslationModel'
    '401':
      description: Unauthorised
    '403':
      description: Forbidden
    '404':
      description: Invalid input
put:
  tags:
    - TranslationController
  operationId: update
  summary: Update a Translation
  requestBody:
    content:
      application/json:
        schema:
          $ref: '#/components/schemas/TranslationModel'
    required: true
  responses:
    "200":
      description: OK
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/TranslationModel'
    '401':
      description: Unauthorised
    '403':
      description: Forbidden
    '404':
      description: Invalid input
post:
  tags:
    - TranslationController
  operationId: save
  summary: Save a Translations
  requestBody:
    content:
      application/json:
        schema:
          $ref: '#/components/schemas/TranslationModel'
    required: true
  responses:
    "200":
      description: OK
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/TranslationModel'
    '401':
      description: Unauthorised
    '403':
      description: Forbidden
    '404':
      description: Invalid input
/translation/{transId}:
get:
  tags:
    - TranslationController
  operationId: fetch
  summary: Fetch a Translation
  parameters:
    - name: transId
      in: path
      required: true
      schema:
        type: integer
        format: int64
  responses:
    "200":
      description: OK
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/TranslationModel'
    '401':
      description: Unauthorised
    '403':
      description: Forbidden
    '404':
      description: Invalid input
delete:
  tags:
    - TranslationController
  operationId: delete
  summary: Delete a Translation
  parameters:
    - name: transId
      in: path
      required: true
      schema:
        type: integer
        format: int64
  responses:
    "200":
      description: OK
      content:
        application/json:
          schema:
            type: object
    '401':
      description: Unauthorised
    '403':
      description: Forbidden
    '404':
      description: Invalid input

/lookupsLang:
get:
  tags:
    - LookupLangController
  operationId: fetchAll_1
  summary: Get All Lookup Langs
  parameters:
    - name: text
      in: query
      required: false
      schema:
        type: string
    - name: lang
      in: query
      required: false
      schema:
        type: string
    - name: sorting
      in: query
      required: false
      schema:
        type: string
    - name: pageable
      in: query
      required: true
      schema:
        $ref: '#/components/schemas/Pageable'
  responses:
    "200":
      description: OK
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/PageLookupLangModel'
    '401':
      description: Unauthorised
    '403':
      description: Forbidden
    '404':
      description: Invalid input
put:
  tags:
    - LookupLangController
  operationId: update_1
  summary: Update a Lookup Lang
  requestBody:
    content:
      application/json:
        schema:
          $ref: '#/components/schemas/LookupLangModel'
    required: true
  responses:
    "200":
      description: OK
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/LookupLangModel'
    '401':
      description: Unauthorised
    '403':
      description: Forbidden
    '404':
      description: Invalid input
post:
  tags:
    - LookupLangController
  operationId: save_1
  summary: Save a Lookup Lang
  requestBody:
    content:
      application/json:
        schema:
          $ref: '#/components/schemas/LookupLangModel'
    required: true
  responses:
    "200":
      description: OK
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/LookupLangModel'
    '401':
      description: Unauthorised
    '403':
      description: Forbidden
    '404':
      description: Invalid input
/lookupsLang/{lookupId}:
get:
  tags:
    - LookupLangController
  operationId: fetch_1
  summary: Fetch a Lookup Lang
  parameters:
    - name: lookupId
      in: path
      required: true
      schema:
        type: integer
        format: int64
  responses:
    "200":
      description: OK
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/LookupLangModel'
    '401':
      description: Unauthorised
    '403':
      description: Forbidden
    '404':
      description: Invalid input
delete:
  tags:
    - LookupLangController
  operationId: delete_1
  summary: Delete a Lookup Lang
  parameters:
    - name: lookupId
      in: path
      required: true
      schema:
        type: integer
        format: int64
  responses:
    "200":
      description: OK
      content:
        application/json:
          schema:
            type: object
    '401':
      description: Unauthorised
    '403':
      description: Forbidden
    '404':
      description: Invalid input

/lookupsData:
get:
  tags:
    - LookupDataController
  operationId: fetchAll_2
  summary: Get All Lookups Data
  parameters:
    - name: text
      in: query
      required: false
      schema:
        type: string
    - name: code
      in: query
      required: false
      schema:
        type: string
    - name: pageable
      in: query
      required: true
      schema:
        $ref: '#/components/schemas/Pageable'
  responses:
    "200":
      description: OK
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/PageLookupDataModel'
    '401':
      description: Unauthorised
    '403':
      description: Forbidden
    '404':
      description: Invalid input
put:
  tags:
    - LookupDataController
  operationId: update_2
  summary: Update a Lookup Data
  requestBody:
    content:
      application/json:
        schema:
          $ref: '#/components/schemas/LookupDataModel'
    required: true
  responses:
    "200":
      description: OK
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/LookupDataModel'
    '401':
      description: Unauthorised
    '403':
      description: Forbidden
    '404':
      description: Invalid input
post:
  tags:
    - LookupDataController
  operationId: save_2
  summary: Save a Lookup Data
  requestBody:
    content:
      application/json:
        schema:
          $ref: '#/components/schemas/LookupDataModel'
    required: true
  responses:
    "200":
      description: OK
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/LookupDataModel'
    '401':
      description: Unauthorised
    '403':
      description: Forbidden
    '404':
      description: Invalid input
/lookupsData/{lookupId}:
get:
  tags:
    - LookupDataController
  operationId: fetch_2
  summary: Fetch a Lookup Data
  parameters:
    - name: lookupId
      in: path
      required: true
      schema:
        type: integer
        format: int64
  responses:
    "200":
      description: OK
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/LookupDataModel'
    '401':
      description: Unauthorised
    '403':
      description: Forbidden
    '404':
      description: Invalid input
delete:
  tags:
    - LookupDataController
  operationId: delete_2
  summary: Delete a Lookup Data
  parameters:
    - name: lookupId
      in: path
      required: true
      schema:
        type: integer
        format: int64
  responses:
    "200":
      description: OK
      content:
        application/json:
          schema:
            type: object
    '401':
      description: Unauthorised
    '403':
      description: Forbidden
    '404':
      description: Invalid input

/lookups:
get:
  tags:
    - LookupController
  operationId: fetchAll_3
  summary: Get All Lookups
  parameters:
    - name: lookupName
      in: query
      required: false
      schema:
        type: string
    - name: text
      in: query
      required: false
      schema:
        type: string
    - name: code
      in: query
      required: false
      schema:
        type: string
    - name: pageable
      in: query
      required: true
      schema:
        $ref: '#/components/schemas/Pageable'
  responses:
    "200":
      description: OK
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/PageLookupModel'
    '401':
      description: Unauthorised
    '403':
      description: Forbidden
    '404':
      description: Invalid input
put:
  tags:
    - LookupController
  operationId: update_3
  summary: Update a Lookup
  requestBody:
    content:
      application/json:
        schema:
          $ref: '#/components/schemas/LookupModel'
    required: true
  responses:
    "200":
      description: OK
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/LookupModel'
    '401':
      description: Unauthorised
    '403':
      description: Forbidden
    '404':
      description: Invalid input
post:
  tags:
    - LookupController
  operationId: save_3
  summary: Save a Lookup
  requestBody:
    content:
      application/json:
        schema:
          $ref: '#/components/schemas/LookupModel'
    required: true
  responses:
    "200":
      description: OK
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/LookupModel'
    '401':
      description: Unauthorised
    '403':
      description: Forbidden
    '404':
      description: Invalid input
/lookups/{lookupId}:
get:
  tags:
    - LookupController
  operationId: fetch_3
  summary: Fetch a Lookup
  parameters:
    - name: lookupId
      in: path
      required: true
      schema:
        type: integer
        format: int64
  responses:
    "200":
      description: OK
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/LookupModel'
    '401':
      description: Unauthorised
    '403':
      description: Forbidden
    '404':
      description: Invalid input
delete:
  tags:
    - LookupController
  operationId: delete_3
  summary: Delete a Lookup
  parameters:
    - name: lookupId
      in: path
      required: true
      schema:
        type: integer
        format: int64
  responses:
    "200":
      description: OK
      content:
        application/json:
          schema:
            type: object
    '401':
      description: Unauthorised
    '403':
      description: Forbidden
    '404':
      description: Invalid input

 components:
  schemas:
  TranslationModel:
    type: object
    properties:
      webId:
        type: integer
        format: int64
      clientId:
        type: integer
        format: int64
      text:
        type: string
      code:
        type: string
      lang:
        type: string
  LookupLangModel:
  type: object
  properties:
    webId:
      type: integer
      format: int64
    lookupDataId:
      type: integer
      format: int64
    clientId:
      type: integer
      format: int64
    text:
      type: string
    lang:
      type: string
    sorting:
      type: integer
      format: int32
LookupDataModel:
  type: object
  properties:
    webId:
      type: integer
      format: int64
    clientId:
      type: integer
      format: int64
    lookupId:
      type: integer
      format: int64
    startDate:
      type: string
      format: date-time
    endDate:
      type: string
      format: date-time
    description:
      type: string
    text:
      type: string
    code:
      type: string
    lookupName:
      type: string
    sorting:
      type: integer
      format: int32
    strAttribute1:
      type: string
    strAttribute2:
      type: string
    strAttribute3:
      type: string
    intAttribute1:
      type: integer
      format: int32
    intAttribute2:
      type: integer
      format: int32
    intAttribute3:
      type: integer
      format: int32
    status:
      type: integer
      format: int32
    lookupLangModels:
      type: array
      items:
        $ref: '#/components/schemas/LookupLangModel'
LookupModel:
  type: object
  properties:
    webId:
      type: integer
      format: int64
    clientId:
      type: integer
      format: int64
    startDate:
      type: string
      format: date-time
    endDate:
      type: string
      format: date-time
    lookupName:
      type: string
    status:
      type: integer
      format: int32
    lookupDataModels:
      type: array
      items:
        $ref: '#/components/schemas/LookupDataModel'
Pageable:
  type: object
  properties:
    offset:
      type: integer
      format: int64
    sort:
      $ref: '#/components/schemas/Sort'
    unpaged:
      type: boolean
    paged:
      type: boolean
    pageSize:
      type: integer
      format: int32
    pageNumber:
      type: integer
      format: int32
Sort:
  type: object
  properties:
    unsorted:
      type: boolean
    sorted:
      type: boolean
    empty:
      type: boolean
PageTranslationModel:
  type: object
  properties:
    totalPages:
      type: integer
      format: int32
    totalElements:
      type: integer
      format: int64
    size:
      type: integer
      format: int32
    content:
      type: array
      items:
        $ref: '#/components/schemas/TranslationModel'
    number:
      type: integer
      format: int32
    sort:
      $ref: '#/components/schemas/Sort'
    numberOfElements:
      type: integer
      format: int32
    first:
      type: boolean
    last:
      type: boolean
    pageable:
      $ref: '#/components/schemas/Pageable'
    empty:
      type: boolean
PageLookupLangModel:
  type: object
  properties:
    totalPages:
      type: integer
      format: int32
    totalElements:
      type: integer
      format: int64
    size:
      type: integer
      format: int32
    content:
      type: array
      items:
        $ref: '#/components/schemas/LookupLangModel'
    number:
      type: integer
      format: int32
    sort:
      $ref: '#/components/schemas/Sort'
    numberOfElements:
      type: integer
      format: int32
    first:
      type: boolean
    last:
      type: boolean
    pageable:
      $ref: '#/components/schemas/Pageable'
    empty:
      type: boolean
PageLookupDataModel:
  type: object
  properties:
    totalPages:
      type: integer
      format: int32
    totalElements:
      type: integer
      format: int64
    size:
      type: integer
      format: int32
    content:
      type: array
      items:
        $ref: '#/components/schemas/LookupDataModel'
    number:
      type: integer
      format: int32
    sort:
      $ref: '#/components/schemas/Sort'
    numberOfElements:
      type: integer
      format: int32
    first:
      type: boolean
    last:
      type: boolean
    pageable:
      $ref: '#/components/schemas/Pageable'
    empty:
      type: boolean
PageLookupModel:
  type: object
  properties:
    totalPages:
      type: integer
      format: int32
    totalElements:
      type: integer
      format: int64
    size:
      type: integer
      format: int32
    content:
      type: array
      items:
        $ref: '#/components/schemas/LookupModel'
    number:
      type: integer
      format: int32
    sort:
      $ref: '#/components/schemas/Sort'
    numberOfElements:
      type: integer
      format: int32
    first:
      type: boolean
    last:
      type: boolean
    pageable:
      $ref: '#/components/schemas/Pageable'
    empty:
      type: boolean

确保您的自定义 yaml/json 文件保存在 resources/static 文件夹下。 然后设置springdoc.swagger-ui.url属性到您的文件名。

example

结构:资源->静态->swagger-config.yaml

财产 :springdoc.swagger-ui.url=/swagger-config.yaml

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何将 Springdoc Swagger UI 指向我自己的 YAML 文件而不是自动生成的文件? 的相关文章

随机推荐

  • Richfaces modalPanel 使用 Ajax 加载

    我在我的项目中使用了 richfaces 特别是标签 rich modalPanel 它允许在页面中显示弹出窗口 为此 我添加了这样的弹出窗口
  • 如何将 reCAPTCHA 设为必填字段?

    我正在使用 Google reCAPTCHA 并且能够将 CAPTCHA 组件添加到表单内的页面中 但是当我提交表单时 没有进行验证来检查验证码是否已解决 提交表单时如何验证验证码组件已被解析 或者 换句话说 如何使我的验证码组件成为必需的
  • NestJS,如何以及在哪里构建响应 DTO

    我一直在使用Java Spring框架来开发微服务 最近 我开始探索 NestJS 并有一个关于构建响应 DTO 的问题 在春天 控制器是轻量级的 它们将调用交给服务层 服务层实现业务逻辑 最后 它们调用负责构建响应 DTO 的 Mappe
  • 在 d3.js 中绘制滚动/移动平均值

    寻找一种在 d3 中绘制滚动 移动平均值的方法 而无需提前操作数据 所以我想通过对每个数据点及其后面的两个数据点进行平均来平滑这条线 我的代码是这样的 var data 3 66 2 76 5 20 1 3 8 90 2 5 70 var
  • 当应用程序处于后台/未运行时,不打开通知单击上的特定活动

    仅当打开应用程序并执行通知单击时 通知单击才会启动指定的活动 如果应用程序处于后台 未运行并且执行了通知单击 则应用程序的 MainActivity 将打开 简而言之 就像应用程序按照 Activity 堆栈正常打开一样 而不是打开 Pen
  • 填充无效且无法移除

    来自评论 一旦我手动将填充设置为 无 问题就消失了 这段代码有什么问题吗 VS2010确实可以编译它 但是从VS2010运行时出现错误 说cs close 填充无效 有人可以帮忙吗 谢谢 public static byte Decrypt
  • 如何从javascript中的字符串中删除“,”

    原始字符串是 a d k 我想删除所有 并使其达到 adk 我尝试了下面的代码 但它不起作用 a d k replace 您没有将替换方法的结果分配回您的变量 当您调用replace时 它会返回一个新字符串 而不修改旧字符串 例如 将其加载
  • Wordpress - 选择/加载子菜单项页面时突出显示父菜单项

    我有一个基本菜单 一些菜单项有子菜单 我对 WordPress 的经验很少 现在没有时间深入研究细节 所以我的问题是 当用户导航到子菜单页面之一时突出显示顶部菜单项的最简单方法是什么 我尝试使用 javascript 和纯 css 通过元素
  • 具有动态高度的 CSS 三角形

    想知道是否有人可以帮助解决我遇到的 css 问题 请参阅此 jsbin http jsbin com uviyat 2 edit http jsbin com uviyat 2 edit 注意 较长的措辞示例 如何使三角形箭头指示器垂直缩放
  • 从 XSL 创建 XSL

    我正在尝试从 XSLT 样式表动态生成 XSLT 文档 当然 原则上这是可行的 但我没有让命名空间正常工作 我希望生成的 XSLT 元素带有 xsl 前缀
  • jquery ui滑块,如果满足某些条件则停止滑动

    使用 jQuery UI Slider 我试图找出如何使滑块在满足某些条件后停止工作 有任何想法吗 我认为在 开始 部分停止事件传播会起作用 但是 事实并非如此 所以我还是一无所知 迷失了方向
  • 您可以使用 RedirectToAction 传递模型吗?

    我正在使用 mvc 2 候选版本 并且想知道是否有任何方法可以使用 RedirectToAction 将模型传递给操作 例如 我有一个编辑操作 它采用 ID 从数据库加载记录 在文本框中显示当前值 并让用户编辑并单击提交 public Ac
  • 无法在 Zsh 中使用颜色;文字有效,但没有出现颜色

    我刚买了一台 Mac 我正在尝试用颜色自定义我的 Zsh 提示符 但我无法让颜色起作用 我不确定是因为 LS COLORS 还是什么原因 这是我的 zshrc export CLICOLOR 1 export LSCOLORS ExFxBx
  • C# 没有私有变量的自定义 getter/setter

    我最近学习了c 所以当我学习写属性时 我被教这样做 public string Name get set 汽车属性太棒了 但现在我想做一些更复杂的事情 所以我需要编写一对自定义访问器 private string Name public s
  • 在 for 循环中重新创建 ArrayList 的最快方法

    在Java中 对一个巨大的矩阵X使用以下函数来打印其列不同的元素 create the list of distinct values List
  • 我应该如何订购 DI/IOC 的 ctor 参数?

    我是一个 DI 新手 所以如果这是错误的方法或一个愚蠢的问题 请原谅我 假设我有一个创建 更新订单的表单 并且我知道它将需要检索要显示的产品和客户列表 我想传递它正在编辑的 Order 对象 但我还想注入 ProductsService 和
  • 作为 Windows 服务运行时,如何获取活动监视器的数量? C++

    当 exe 作为 Windows 服务运行时 我在检索活动监视器的数量时遇到了问题 我尝试使用 EnumDisplayDevices 和 GetSystemMetrics SM CMONITROS 来获取监视器的数量 这两种方法在以控制台模
  • 如何更改本地sql server sa密码?

    我是计算机的本地管理员 如何更改本地安装的 sql server 2008 的 sa 密码 注意 我不知道sa帐户的密码 该线程的回复确实很晚 但我刚刚丢失并重置了 SA 的密码 按照以下简单步骤操作即可完成 在 Windows 身份验证模
  • Facebook Like Box:如何检测用户是否已经喜欢该页面?

    我在我的博客中安装了 Like Box 我想知道用户是否已经喜欢我的页面 我想向我的读者实现这样的东西 因为如果他们已经喜欢我的页面 我想向他们提供隐藏的内容 是否有一个事件可以检测用户是否已经喜欢 赞 框中的页面 如果您使用的是 XFBM
  • 如何将 Springdoc Swagger UI 指向我自己的 YAML 文件而不是自动生成的文件?

    我创建了一个 Spring Boot RESTFul 微服务 对于文档 我创建了一个 swagger yaml 文件 但我不知道如何运行该文件 为了创建 swagger yaml 文件 我使用了 OpenAPI 规范 我知道我们有一个 Sw