[英]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: "successful operation"
schema:
$ref: "#/definitions/Result"
definitions:
ByteArrayOutputStream:
type: "object"
Request:
...
Result:
type: "object"
properties:
...
pdf:
$ref: "#/definitions/ByteArrayOutputStream"
更新:我已經更改了我的 api 並用字符串替換了 ByteArrayOutputSram。 我使用 Base64 編碼和解碼來做到這一點。 這幫助我避免了這些問題並且工作正常。
當你使用它時會發生這種情況。 你只需要覆蓋那個類,你的問題就會解決。
問候。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.