0

我已经使用以下依赖项配置了我的 pom 文件。请参阅我希望为其生成接口的 YAML 文件。不知何故,当创建接口时,它被绑定到org.springframework.core.io.Resource而不是我在 YAML 文件中提供的对象。有人可以帮助我如何将 Resource 对象与 YAML 文件中提供的对象联系起来吗?

    <dependency>
        <groupId>io.swagger</groupId>
        <artifactId>swagger-annotations</artifactId>
        <version>1.5.21</version>
    </dependency>
    <dependency>
        <groupId>io.swagger</groupId>
        <artifactId>swagger-models</artifactId>
        <version>1.6.0</version>
    </dependency>
                <plugin>
                <groupId>io.swagger.codegen.v3</groupId>
                <artifactId>swagger-codegen-maven-plugin</artifactId>
                <version>3.0.18</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>${project.basedir}/src/main/resources/static/example-api.yaml</inputSpec>
                            <language>spring</language>
                            <output>${project.build.directory}/generated-sources/</output>
                            <generateSupportingFiles>false</generateSupportingFiles>
                            <apiPackage>com.company.package.package2.api</apiPackage>
                            <modelPackage>com.company.package.package2.objects</modelPackage>
                            <configOptions>
                                <interfaceOnly>true</interfaceOnly>
                            </configOptions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

YAML 文件

openapi: "3.0.0"
info:
  version: 1.0.0
  title: Example APIs
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
  contact:
    email: team@company.com
servers:
  - url: http://localhost:8080
paths:
  /resources/{id}:
    patch:
      summary: update resource
      operationId: patchResource
      tags:
        - resource
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        description: description of requestbody
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Resource'
      responses:
        '200':
          description: Updated Resource
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Resource"
components:
  schemas:
    Resource:
      type: object
      description: The entity.
      properties:
        id:
          description: Unique identifier for the object.
          type: string
          nullable: false
        action:
          description: Operation to be performed on the resource.
          type: string
          nullable: false

4

0 回答 0