I'm trying to at a minimum add a description to a property of a returned object, so that I can give users context of what they're trying to return, but I'm having no luck.
I've tried Jackson Annotations like @JsonPropertyDescription, and I've tried swagger annotations like @Parameter(schema=@Schema(description="foo")) but nothing seems to influence the generated swagger document.
Is there an example anywhere of adding context to the schema? Ideally I'd like to add examples and a format, and in some cases a description...
@OpenApiResponse(status = RES_OK, content = @OpenApiContent(from = Committee.class))
and committee is
public class Committee {
@Parameter(
schema = @Schema(
type = "string",
format = "uint64",
description = "some description"
)
)
public String slot;
}
I was expecting to see
"committee":
{
"type":"object",
"properties":{
"slot": :{
"type":"string",
"format":"uint64",
"description": "some description"
}
}
}
Some swagger documents I've been looking at have all of this information set, but I'm really finding it hard to replicate in this framework...
I believe it's just @Schema(description = "some description"). At least in kotlin I don't need the @Parameter. What are you seing in the documentation? Is it at least picking up the class correctly?
yep the committee snippet at the end is the schema definition i'm getting for the committee, with the extra fields. So the schema entry is there, and it's referenced from the API, but I can't add the extra context.
I Annotated as suggested and it has come through to the schema! So that's awesome! Thanks for the suggestion. (I added example below, it works too :) )
@Schema(
type = "string",
format = "uint64",
description = "some description"
example="1234567890"
)