英文:
Swagger-Codegen generates empty class instead of an instance of ByteArrayOutputStream
问题
以下是翻译好的内容:
我目前正在尝试使用swagger-codegen生成API。唯一的问题是swagger生成了一个名为"ByteArrayOutputStream"的空类,而不是一个ByteArrayOutputStream的实例。生成的类还没有任何属性。
生成的swagger-yaml还像这样定义了ByteArrayOutputStream:
ByteArrayOutputStream:
type: "object"
这是swagger.yaml的相关部分。我已经用"..."替换了一些值并缩短了文件。
---
swagger: "2.0"
info:
version: "1.0"
title: "..."
contact:
name: "..."
url: "..."
host: "..."
basePath: "/"
schemes:
- "https"
paths:
/rest/v1/pkw:
post:
summary: "..."
description: ""
operationId: "..."
produces:
- "application/json"
parameters:
- in: "body"
name: "body"
required: false
schema:
$ref: "#/definitions/Request"
responses:
200:
description: "操作成功"
schema:
$ref: "#/definitions/Result"
definitions:
ByteArrayOutputStream:
type: "object"
Request:
...
Result:
type: "object"
properties:
...
pdf:
$ref: "#/definitions/ByteArrayOutputStream"
英文:
I'm currently trying to generate an api with swagger-codegen. The only problem i have is that swagger generates an empty class with the name "ByteArrayOutputStream" instead of an instance of ByteArrayOutputStream. The generated class also contains no attributes.
The generated swagger-yaml also defines ByteArrayOutputStream like this:
ByteArrayOutputStream:
type: "object"
This is the relevant part of the swagger.yaml. I've replaced some of the values with "..." and shortened the file.
---
swagger: "2.0"
info:
version: "1.0"
title: "..."
contact:
name: "..."
url: "..."
host: "..."
basePath: "/"
schemes:
- "https"
paths:
/rest/v1/pkw:
post:
summary: "..."
description: ""
operationId: "..."
produces:
- "application/json"
parameters:
- in: "body"
name: "body"
required: false
schema:
$ref: "#/definitions/Request"
responses:
200:
description: "successful operation"
schema:
$ref: "#/definitions/Result"
definitions:
ByteArrayOutputStream:
type: "object"
Request:
...
Result:
type: "object"
properties:
...
pdf:
$ref: "#/definitions/ByteArrayOutputStream"
</details>
# 答案1
**得分**: 0
更新:
我已经更改了我的API,并且用字符串替换了ByteArrayOutputStream。我使用Base64编码和解码来实现这一点。这帮助我避免了问题,而且运行良好。
<details>
<summary>英文:</summary>
Update:
I've changed my api and replaced ByteArrayOutputStram by a String. I use Base64 encoding and decoding to do so. This helped me avoid the problems and works fine.
</details>
# 答案2
**得分**: 0
发生这种情况是在你使用它时。你只需覆盖那个类,你的问题就会解决。
祝好。
<details>
<summary>英文:</summary>
That's happen when you use it. You just have to overrides that class and your problem will fix.
Regards.
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论