小编use*_*400的帖子

当使用 swagger codegen 获取 'List<byte[]>' 而不是简单的 'byte[]' 时

byte[] 在 swagger 文件中被建模为byte[]. 当使用 swagger codegen 时,我们得到的List<byte[]>不仅仅是byte[]

Swagger.json

"document": {
    "type": "array",
    "items": 
    {
        "type": "string",
        "format": "byte"
    }
}
Run Code Online (Sandbox Code Playgroud)

pom.xml

<plugin>
    <groupId>io.swagger</groupId>
    <artifactId>swagger-codegen-maven-plugin</artifactId>
    <version>2.3.1</version>
    <executions>
        <execution>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <inputSpec>${project.basedir}/src/main/resources/swagger.json</inputSpec>
                <language>java</language>
                <configOptions>
                   <sourceFolder>src/gen/java/main</sourceFolder>
                </configOptions>
            </configuration>
        </execution>
    </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

maven-plugin swagger swagger-codegen

7
推荐指数
1
解决办法
2万
查看次数

标签 统计

maven-plugin ×1

swagger ×1

swagger-codegen ×1