我刚刚尝试在Swagger编辑器中为JSON Swagger文件创建Java。 不幸的是,如果我尝试生成客户端,则不会发生任何事情。
在Chrome的开发工具控制台中,我可以看到一个异常,但我不知道出了什么问题以及在哪里可以找到更详细的信息。
POST https://generator.swagger.io/api/gen/clients/java 500 (Request failed.)
index.js:1 Uncaught (in promise) Error: Request failed.
at index.js:1
at tryCatch (runtime.js:62)
at Generator.invoke [as _invoke] (runtime.js:296)
at Generator.e.(/anonymous function) [as next] (https://editor.swagger.io/dist/swagger-editor-standalone-preset.js:1:104152)
at step (asyncToGenerator.js:17)
at asyncToGenerator.js:28
这是用于生成Java客户端的JSON文件:
{
"swagger":"2.0",
"info":{
"description":"REST API zur Anlage und Modifikation der Daten",
"title":"Aktivierung / Aktualisierung / Deaktivierung der Daten",
"version":"1"
},
"host":"myhost.server.local:8080",
"basePath":"/metadata-webapp",
"paths":{
"/metadata/deactivate":{
"put":{
"summary":"Metadata Deactivation",
"description":"",
"operationId":"deactivate",
"consumes":[
"application/json"
],
"produces":[
"application/json"
],
"parameters":[
{
"in":"body",
"name":"body",
"description":"metadata key",
"required":true,
"schema":{
"$ref":"#/definitions/MetadataKey"
}
}
],
"responses":{
"200":{
"description":"Request was processed"
},
"400":{
"description":"Bad Request, falls Validierung auf Request Objekt fehlschlägt"
},
"500":{
"description":"Interner Fehler"
}
}
}
},
"/metadata/individual":{
"post":{
"summary":"\tMetadata Insert Individual",
"description":"",
"operationId":"saveIndividual",
"consumes":[
"application/json"
],
"produces":[
"application/json"
],
"parameters":[
{
"in":"body",
"name":"body",
"description":"metadata",
"required":true,
"schema":{
"$ref":"#/definitions/MetadataIndividualInsert"
}
}
],
"responses":{
"200":{
"description":"OK"
},
"400":{
"description":"Invalid Metadata",
"schema":{
"$ref":"#/definitions/MetadataResponse"
}
},
"404":{
"description":"Not found",
"schema":{
"type":"string"
}
},
"405":{
"description":"Method Not Allowed",
"schema":{
"$ref":"#/definitions/MetadataResponse"
}
},
"409":{
"description":"Conflict",
"schema":{
"$ref":"#/definitions/MetadataResponse"
}
},
"500":{
"description":"Internal Server Error"
}
}
},
"put":{
"summary":"Metadata Update Individual",
"description":"",
"operationId":"updateIndividual",
"consumes":[
"application/json"
],
"produces":[
"application/json"
],
"parameters":[
{
"in":"body",
"name":"body",
"description":"metadata",
"required":true,
"schema":{
"$ref":"#/definitions/MetadataUpdate"
}
}
],
"responses":{
"200":{
"description":"Request was processed"
},
"400":{
"description":"Bad Request, falls Validierung auf Request Objekt fehlschlägt"
},
"500":{
"description":"Interner Fehler"
}
}
}
},
"/metadata":{
"post":{
"summary":"\tMetadata Insert",
"description":"",
"operationId":"save",
"consumes":[
"application/json"
],
"produces":[
"application/json"
],
"parameters":[
{
"in":"body",
"name":"body",
"description":"metadata",
"required":true,
"schema":{
"$ref":"#/definitions/MetadataInsert"
}
}
],
"responses":{
"200":{
"description":"OK"
},
"400":{
"description":"Invalid Metadata",
"schema":{
"$ref":"#/definitions/MetadataResponse"
}
},
"404":{
"description":"Not found",
"schema":{
"type":"string"
}
},
"405":{
"description":"Method Not Allowed",
"schema":{
"$ref":"#/definitions/MetadataResponse"
}
},
"409":{
"description":"Conflict",
"schema":{
"$ref":"#/definitions/MetadataResponse"
}
},
"500":{
"description":"Internal Server Error"
}
}
},
"put":{
"summary":"Metadata Update",
"description":"",
"operationId":"update",
"consumes":[
"application/json"
],
"produces":[
"application/json"
],
"parameters":[
{
"in":"body",
"name":"body",
"description":"metadata",
"required":true,
"schema":{
"$ref":"#/definitions/MetadataUpdate"
}
}
],
"responses":{
"200":{
"description":"Request was processed"
},
"400":{
"description":"Bad Request, falls Validierung auf Request Objekt fehlschlägt"
},
"500":{
"description":"Interner Fehler"
}
}
}
}
},
"definitions":{
"MetadataKey":{
"type":"object",
"required":[
"itemId"
],
"properties":{
"itemId":{
"type":"string",
"minLength":1,
"maxLength":36
},
"itemCode":{
"type":"string",
"minLength":0,
"maxLength":10
}
}
},
"MetadataResponse":{
"type":"object",
"required":[
"itemId"
],
"properties":{
"itemId":{
"type":"string",
"minLength":1,
"maxLength":36
},
"itemCode":{
"type":"string",
"minLength":0,
"maxLength":10
},
"returnCode":{
"type":"string",
"enum":[
"OK",
"FAULT",
"IRRELEVANT",
"STATUS",
"TECHNICAL_ERROR"
]
},
"message":{
"type":"string"
}
}
},
"MetadataUpdate":{
"type":"object",
"required":[
"aType",
"codeFrom",
"iType",
"isCodeRangeNumeric",
"lengthOfCodes",
"numberOfCodes",
"oCategory",
"itemId",
"myExtraIds",
"status",
"targetCategory",
"validDays",
"validFrom",
"validUntil"
],
"properties":{
"itemId":{
"type":"string",
"minLength":1,
"maxLength":36
},
"itemCode":{
"type":"string",
"minLength":0,
"maxLength":10
},
"uuid":{
"type":"string"
},
"validFrom":{
"type":"string",
"format":"date-time",
"example":"yyyy-MM-dd'T'HH:mm:ssZ"
},
"validUntil":{
"type":"string",
"format":"date-time",
"example":"yyyy-MM-dd'T'HH:mm:ssZ"
},
"validUntilOriginal":{
"type":"string",
"format":"date-time"
},
"validDays":{
"type":"integer",
"format":"int32"
},
"visibleFrom":{
"type":"string",
"format":"date-time",
"example":"yyyy-MM-dd'T'HH:mm:ssZ"
},
"visibleTo":{
"type":"string",
"format":"date-time",
"example":"yyyy-MM-dd'T'HH:mm:ssZ"
},
"aType":{
"type":"integer",
"format":"int32",
"description":"OFFLINE(1),ONLINE(2),BOTH(3)"
},
"multiRedeem":{
"type":"integer",
"format":"int32",
"minimum":1,
"maximum":2147483647
},
"targetCategory":{
"type":"integer",
"format":"int32",
"description":"desc"
},
"iType":{
"type":"integer",
"format":"int32",
"description":"desc"
},
"oCategory":{
"type":"integer",
"format":"int32",
"description":"desc"
},
"incentiveValueFrom":{
"type":"integer",
"format":"int32"
},
"incentiveValueTo":{
"type":"integer",
"format":"int32"
},
"externalID":{
"type":"string"
},
"couponID":{
"type":"string"
},
"codeFrom":{
"type":"string",
"minLength":1,
"maxLength":2147483647
},
"codeTo":{
"type":"string"
},
"infoText":{
"type":"string"
},
"status":{
"type":"integer",
"format":"int32",
"description":"desc"
},
"numberOfCodes":{
"type":"integer",
"format":"int32",
"minimum":1,
"maximum":2147483647
},
"lengthOfCodes":{
"type":"integer",
"format":"int32",
"minimum":4,
"maximum":2147483647
},
"isCodeRangeNumeric":{
"type":"boolean"
},
"interfaceOrigin":{
"type":"integer",
"format":"int32",
"description":"desc"
},
"myExtraIds":{
"type":"array",
"items":{
"type":"string"
},
"maxItems":2147483647,
"minItems":1
}
}
},
"MetadataIndividualInsert":{
"type":"object",
"required":[
"aType",
"codeFrom",
"iType",
"isCodeRangeNumeric",
"lengthOfCodes",
"numberOfCodes",
"oCategory",
"itemId",
"myExtraIds",
"status",
"targetCategory",
"validDays",
"validFrom",
"validUntil"
],
"properties":{
"itemId":{
"type":"string",
"minLength":1,
"maxLength":36
},
"itemCode":{
"type":"string",
"minLength":0,
"maxLength":10
},
"uuid":{
"type":"string"
},
"validFrom":{
"type":"string",
"format":"date-time",
"example":"yyyy-MM-dd'T'HH:mm:ssZ"
},
"validUntil":{
"type":"string",
"format":"date-time",
"example":"yyyy-MM-dd'T'HH:mm:ssZ"
},
"validUntilOriginal":{
"type":"string",
"format":"date-time"
},
"validDays":{
"type":"integer",
"format":"int32"
},
"visibleFrom":{
"type":"string",
"format":"date-time",
"example":"yyyy-MM-dd'T'HH:mm:ssZ"
},
"visibleTo":{
"type":"string",
"format":"date-time",
"example":"yyyy-MM-dd'T'HH:mm:ssZ"
},
"aType":{
"type":"integer",
"format":"int32",
"description":"OFFLINE(1),ONLINE(2),BOTH(3)"
},
"multiRedeem":{
"type":"integer",
"format":"int32",
"minimum":1,
"maximum":2147483647
},
"targetCategory":{
"type":"integer",
"format":"int32",
"description":"desc"
},
"iType":{
"type":"integer",
"format":"int32",
"description":"desc"
},
"oCategory":{
"type":"integer",
"format":"int32",
"description":"desc"
},
"incentiveValueFrom":{
"type":"integer",
"format":"int32"
},
"incentiveValueTo":{
"type":"integer",
"format":"int32"
},
"externalID":{
"type":"string"
},
"couponID":{
"type":"string"
},
"codeFrom":{
"type":"string",
"minLength":1,
"maxLength":2147483647
},
"codeTo":{
"type":"string"
},
"infoText":{
"type":"string"
},
"status":{
"type":"integer",
"format":"int32",
"description":"desc"
},
"numberOfCodes":{
"type":"integer",
"format":"int32",
"minimum":1,
"maximum":2147483647
},
"lengthOfCodes":{
"type":"integer",
"format":"int32",
"minimum":4,
"maximum":2147483647
},
"isCodeRangeNumeric":{
"type":"boolean"
},
"interfaceOrigin":{
"type":"integer",
"format":"int32",
"description":"desc"
},
"myExtraIds":{
"type":"array",
"items":{
"type":"string"
},
"maxItems":2147483647,
"minItems":1
}
}
},
"MetadataInsert":{
"type":"object",
"required":[
"aType",
"codeFrom",
"iType",
"isCodeRangeNumeric",
"lengthOfCodes",
"numberOfCodes",
"oCategory",
"itemId",
"myExtraIds",
"status",
"targetCategory",
"validDays",
"validFrom",
"validUntil"
],
"properties":{
"itemId":{
"type":"string",
"minLength":1,
"maxLength":36
},
"itemCode":{
"type":"string",
"minLength":0,
"maxLength":10
},
"uuid":{
"type":"string"
},
"validFrom":{
"type":"string",
"format":"date-time",
"example":"yyyy-MM-dd'T'HH:mm:ssZ"
},
"validUntil":{
"type":"string",
"format":"date-time",
"example":"yyyy-MM-dd'T'HH:mm:ssZ"
},
"validUntilOriginal":{
"type":"string",
"format":"date-time"
},
"validDays":{
"type":"integer",
"format":"int32"
},
"visibleFrom":{
"type":"string",
"format":"date-time",
"example":"yyyy-MM-dd'T'HH:mm:ssZ"
},
"visibleTo":{
"type":"string",
"format":"date-time",
"example":"yyyy-MM-dd'T'HH:mm:ssZ"
},
"aType":{
"type":"integer",
"format":"int32",
"description":"OFFLINE(1),ONLINE(2),BOTH(3)"
},
"multiRedeem":{
"type":"integer",
"format":"int32",
"minimum":1,
"maximum":2147483647
},
"targetCategory":{
"type":"integer",
"format":"int32",
"description":"desc"
},
"iType":{
"type":"integer",
"format":"int32",
"description":"desc"
},
"oCategory":{
"type":"integer",
"format":"int32",
"description":"desc"
},
"incentiveValueFrom":{
"type":"integer",
"format":"int32"
},
"incentiveValueTo":{
"type":"integer",
"format":"int32"
},
"externalID":{
"type":"string"
},
"couponID":{
"type":"string"
},
"codeFrom":{
"type":"string",
"minLength":1,
"maxLength":2147483647
},
"codeTo":{
"type":"string"
},
"infoText":{
"type":"string"
},
"status":{
"type":"integer",
"format":"int32",
"description":"desc"
},
"numberOfCodes":{
"type":"integer",
"format":"int32",
"minimum":1,
"maximum":2147483647
},
"lengthOfCodes":{
"type":"integer",
"format":"int32",
"minimum":4,
"maximum":2147483647
},
"isCodeRangeNumeric":{
"type":"boolean"
},
"interfaceOrigin":{
"type":"integer",
"format":"int32",
"description":"desc"
},
"myExtraIds":{
"type":"array",
"items":{
"type":"string"
},
"maxItems":2147483647,
"minItems":1
}
}
}
}
}
有人可以给我提示做什么或去哪里看吗?
答案 0 :(得分:1)
此问题是由规范中数组定义中的maxItems
值过大引起的:
"maxItems":2147483647
它会在Swagger Codegen中导致内存不足错误,有关详细信息,请参见this issue。
解决方法是从规范中删除maxItems
。