在 openapi 版本 3.1.0 中使用 openapi-generator-maven-plugin 时出现 org.openapitools.codegen.SpecValidationException

问题描述 投票:0回答:1

我收到 [错误] 解析 ./paths/daas/res_prod_acptd_art_cnts.yaml 时出错 java.net.URISyntaxException:索引 2 处的不透明部分中存在非法字符,org.openapitools.codegen.SpecValidationException - 以下 yaml 的索引 2 处的不透明部分中存在非法字符

openapi: 3.1.0
info:
  title: test
  description: test
  # TODO: termsOfService field should be added later
  contact:
    name: test Support
    email: test
  version: 0.0.1
  license: 
    name: Copyright 
    identifier: EPL-2.0

servers:
- url: http://localhost:8080/api
  description: Localhost for development purposes
  
# TODO: Add the security requirments object later
security: []
tags:
  - name: DaaS RES Production Service
    description: Research workflow Production stage related DaaS Production Service APIs
  
paths:
  # Production Service
  /{tenantId}/counts:
    $ref: 'paths/daas/res_prod_acptd_art_cnts.yaml'

$ref: 'paths/daas/res_prod_acptd_art_cnts.yaml'

post:
  summary: Production Accepted Article Counts
  description: API to request counts of production accepted articles by article classification type and other specified global filtering criteria.
  tags:
    - DaaS RES Production Service
  operationId: postProductionAcceptedArticleCounts
  requestBody:
    description: Contains the parameter combination that must be applied to generate the response
    content:
      'application/json':
        schema:
          $ref: '../../components/daas/requestBodies/ReqPayloadProdAcptdArtCnts.yaml'
        examples:
          example-1:
            value:
              $ref: '../../components/daas/examples/ReqExProdAcptdArtCnts.yaml'
          example-2:
            value:
              $ref: '../../components/daas/examples/ReqEx2ProdAcptdArtCnts.yaml'
          example-3:
            value:
              $ref: '../../components/daas/examples/ReqEx3ProdAcptdArtCnts.yaml'
          example-4:
            value:
              $ref: '../../components/daas/examples/ReqEx4ProdAcptdArtCnts.yaml'    
    required: true
  responses:
    '200':
      $ref: '../../components/daas/responses/ResPayloadProdAcptdArtCnts.yaml'
    '400':
      $ref: '../../components/daas/responses/400BadRequest.yaml'
    '401':
      $ref: '../../components/daas/responses/401Unauthorized.yaml'
    '415':
      $ref: '../../components/daas/responses/415UnsupportedMediaType.yaml'
    '500':
      $ref: '../../components/daas/responses/500InternalServerError.yaml'
parameters:
- name: tenantId
  in: path
  description: Tenant ID of the tenant of which the caller is invoking the API of.
  required: true
  schema:
    type: string
  example: '1001'
openapi openapi-generator-maven-plugin
1个回答
0
投票

尝试在 Maven 插件配置中使用 ${project.baseUri} 而不是 ${project.basedir}

<build>
    <plugins>
        <plugin>
            <groupId>org.openapitools</groupId>
            <artifactId>openapi-generator-maven-plugin</artifactId>
            <version>7.10.0</version>
            <executions>
                <execution>
                    <id>generateModels</id>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <inputSpec>${project.baseUri}/src/main/resources/META-INF/openapi.yaml</inputSpec>
© www.soinside.com 2019 - 2024. All rights reserved.