Swagger doc für api-Reaktion (Typ-Liste)
Ich bin mit swagger zum generieren der Dokumentation von mein-REST-API. Aber ich habe Probleme angeben, die Reaktionen von einigen API-Aufrufe.
Dies ist mein code:
@GET
@Path("/self/activities")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Get all activities created by this user",
notes = "Returns the list that the authenticated user (JWT) has created",
response = Activity.class,
responseContainer = "List")
@ApiResponses(value = {
@ApiResponse(code = 400, response = ErrorResponse.Error.class, responseContainer = "List", message = "There was something wrong in the request and therefore could not be processed (headers, json syntax/content)"),
@ApiResponse(code = 500, response = ErrorResponse.Error.class, responseContainer = "List", message = "Unknown Internal server error")})
public void getActivities(...){...}
- Und das ist der doc, den es erzeugt:
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/Activity"
}
}
},
"400" : {
"description" : "There was something wrong in the request and therefore could not be processed (headers, json syntax/content)",
"schema" : {
"$ref" : "#/definitions/Error"
}
},
"500" : {
"description" : "Unknown Internal server error",
"schema" : {
"$ref" : "#/definitions/Error"
}
}
}
Und ich verstehe nicht, warum die Fehlermeldungen sind nicht vom Typ "Array", wie die 200 Antwort. Was ich möchte ist, dass alle Antworten das gleiche format wie die 200-Antworten (array-Elemente):
"500" : {
"description" : "Uknown interval server error",
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/Error"
}
}
}
Vielen Dank für Ihre Zeit.
- Welche version von Fors-core verwendest du hier?
Du musst angemeldet sein, um einen Kommentar abzugeben.
400-und 500-Fehler Antwort liefert ein ErrorResponse. Und nicht ein array.
responseContainer = "List"
. Und ich bin mir ziemlich sicher, dass dies der Weg, es zu tun, weil Wenn ich die 200 Antwort in dem '@ApiResponses' in diesem format funktioniert es.