SMILEY4 / ktor-swagger-ui

Kotlin Ktor plugin to generate OpenAPI and provide Swagger UI
Apache License 2.0
150 stars 25 forks source link

How to add a path that is not in the ktor project #89

Closed mcxinyu closed 5 months ago

mcxinyu commented 5 months ago

Hey SMILEY4 , your work is great. Thank you.

I have an idea or a requirement where I want to declare an API in swagger that is not inside the project. For example a certain API for uploading files which is provided by a third party service provider and I need to declare it in the project so that other colleagues can use it.

I was originally able to handle it this way using swagger yaml, but there doesn't seem to be a possibility to implement it in the functionality provided by this repository.

paths:
  /:
    post:
      tags:
        - Storage
      servers:
        - url: "https://upload.xxxup.com"
          description: "huadong"
        - url: "https://upload-z2.xxxup.com"
          description: "huanan"
      summary: "Upload file to Qi Niu"
      description: "Upload file to Qi Niu, Here is the documentation..."
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - token
                - file
              properties:
                token:
                  description: "upload certificate"
                  type: string
                file:
                  description: "File to upload"
                  type: string
                  format: binary
      responses:
        "200":
          description: "OK"
          content:
            '*/*':
              schema:
                $ref: "#/components/schemas/UserStorageQiniu"
        "500":
          description: "Internal Server Error"
          content:
            '*/*':
              schema:
                $ref: "#/components/schemas/ResponseModel"