如何运行swagger.yaml文件?

oknwwptz  于 2021-06-27  发布在  Java
关注(0)|答案(1)|浏览(451)

我创建了一个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
ia2d9nvy

ia2d9nvy1#

请参考这个链接:swagger,因为它提供了swaggerapi的完整信息。

相关问题