-
We have a class With Swagger annotations, the object looked like this: @Schema(description = "Data for comparing two PDF documents")
public class PdfComparisonFiles {
@Schema(description = "The expected PDF document", format = "binary", type = "string")
@NotNull
private Binary expected;
@Schema(description = "The actual PDF document", format = "binary", type = "string")
@NotNull
private Binary actual;
...
} This resulted in the following part of "PdfComparisonFiles" : {
"required" : [ "actual", "expected" ],
"type" : "object",
"properties" : {
"actual" : {
"type" : "string",
"description" : "The actual PDF document",
"format" : "binary"
},
"expected" : {
"type" : "string",
"description" : "The expected PDF document",
"format" : "binary"
}
},
"description" : "Data for comparing two PDF documents"
} And in SwaggerUI, I get two buttons for uploading the files. Trying the same with the Eclipse MicroProfile annotations: @Schema(description = "Data for comparing two PDF documents")
public class PdfComparisonFiles {
@Schema(description = "The expected PDF document", format = "binary", type = SchemaType.STRING)
@NotNull
private Binary expected;
@Schema(description = "The actual PDF document", format = "binary", type = SchemaType.STRING)
@NotNull
private Binary actual;
...
} But here I first get an error message in SwaggerUI:
And the result in "PdfComparisonFiles" : {
"description" : "Data for comparing two PDF documents",
"required" : [ "expected", "actual" ],
"type" : "object",
"properties" : {
"expected" : {
"format" : "binary",
"description" : "The expected PDF document",
"type" : "object",
"allOf" : [ {
"$ref" : "#/components/schemas/Binary"
} ]
},
"actual" : {
"format" : "binary",
"description" : "The actual PDF document",
"type" : "object",
"allOf" : [ {
"$ref" : "#/components/schemas/Binary"
} ]
}
}
} So my question is: What do I have to annotate to get the same result as with Swagger annotations? Thanks for any help! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
@cristalp , try placing |
Beta Was this translation helpful? Give feedback.
-
Well, I added Now however, it just generates "PdfComparisonFiles" : {
"description" : "Die Daten für den Vergleich zweier PDF-Dokumente",
"required" : [ "expected", "actual" ],
"type" : "object",
"properties" : {
"expected" : {
"description" : "Das erwartete PDF-Dokument",
"type" : "string"
},
"actual" : {
"description" : "Das tatsächliche PDF-Dokument",
"type" : "string"
}
}
} And SwaggerUI just shows two text fields. I don't quite understand what you mean with "any other differences". In the end, the But going all the way and adding everything to both fields (i.e. "PdfComparisonFiles" : {
"description" : "Die Daten für den Vergleich zweier PDF-Dokumente",
"required" : [ "expected", "actual" ],
"type" : "object",
"properties" : {
"expected" : {
"format" : "binary",
"description" : "Das erwartete PDF-Dokument",
"type" : "string"
},
"actual" : {
"format" : "binary",
"description" : "Das tatsächliche PDF-Dokument",
"type" : "string"
}
}
} |
Beta Was this translation helpful? Give feedback.
That's correct. If you want to simply it further, the
type
is superfluous when theimplementation
isString