question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: @ApiModelProperty example support number type

See original GitHub issue

I’d like to request a feature which will allow example field of ApiModelProperty support number type.

For latest release version (1.5.0), if you use example like this:

        @ApiModelProperty(dataType = "double", required = true, example = "1234")
    private Double numberField;

The generated swagger spec looks like:

 "numberField" : {
          "type" : "number",
          "format" : "double",
          "example" : "1349"
        }

Which I believe should be:

 "numberField" : {
          "type" : "number",
          "format" : "double",
          "example" : 1349
        }

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
vinayshankarcommented, Oct 19, 2016

@etyrrill Can you explain how you used Property.example to format the @ApiModelProperty example value? I have the annotation on the property of the class. class ClassName { @ApiModelProperty(name = "name", value = "value", example = "[\"v1\", \"v2\"]") private List<String> values; } Now what do I have to do with Property.class and Property.example ?

0reactions
manjambocommented, Oct 24, 2018

I think this is a similar issue:

@JsonProperty("year")
@ApiModelProperty(required = true, example = "2020", dataType = "java.lang.String")
private final Year year;
...
class Year {
  @JsonProperty("year") // this has no effect on the outcome whther present or not
  private final String year;
}

gives me

...
"year": 2020
...

but I’d like

...
"year": "2020"
...
Read more comments on GitHub >

github_iconTop Results From Across the Web

swagger @ApiModelProperty example value for List<String ...
I managed to get this to work, generating a List of Strings. Within the ApiModelProperty with springfox 2, write your example as follows:...
Read more >
ApiModelProperty (swagger-annotations 1.5.0 API)
Allows a model property to be hidden in the Swagger model definition. ... Specifies a reference to the corresponding type definition, overrides any...
Read more >
Guide - 7.10.12.2 Migrating to OpenApi 3.0 and Swagger 2.X ...
Examples for Operations ... Only if the decorated getter is not an array type. ... @APIModelProperty(readOnly = true), @Schema(accessMode=AccessMode.
Read more >
Swagger - elide.io
Prune Fields - All GET requests support JSON-API sparse fields query parameter ... example and value fields are extracted from ApiModelProperty annotations.
Read more >
Top 5 class-validator Code Examples - Snyk
To help you get started, we've selected a few class-validator examples, ... 0) { // return BAD REQUEST status code and errors array...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found