我有几个Yaml文件,其中许多组件都相同。例如,我有10个Language.java文件,它们的类使用不同的包生成,因此无法在代码中编写通用转换器,并且在项目中有一些复制粘贴代码。是否可以通过某种方式做到这一点?
此外,我正在使用Java 8和Maven从庞大的文件中生成Java代码:
<plugins>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>${openapi-generator.version}</version>
<executions>
<execution>
<id>commons</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/common.yaml</inputSpec>
<generatorName>spring</generatorName>
<apiPackage>mypackage.api</apiPackage>
<modelPackage>mypackage.model</modelPackage>
<configOptions>
<dateLibrary>java8</dateLibrary>
<interfaceOnly>true</interfaceOnly>
</configOptions>
</configuration>
</execution>
<execution>
<id>forms</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/a.yaml</inputSpec>
<generatorName>spring</generatorName>
<apiPackage>mypackage.a.api</apiPackage>
<modelPackage>mypackage.a.model</modelPackage>
<configOptions>
<dateLibrary>java8</dateLibrary>
<interfaceOnly>true</interfaceOnly>
</configOptions>
</configuration>
</execution>
PLENTY OF OTHER YAML FILES AND PACKAGES GENERATING THE SAME COMMON CLASSES like Languages
招摇:
openapi: "3.0.0"
info:
version: 1.0.0
title: Swagger Commons
components:
schemas:
Languages:
type: array
items:
type: string
但这不能在swagger io中验证为路径
结构错误应具有必需的属性“路径” missingProperty:路径
答案 0 :(得分:0)
如消息所示,您的swagger文件应具有path
属性。