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.

Define custom formats with ApiModelProperty and ApiParam

See original GitHub issue
  • What version of the library are you using? 2.8.0

What kind of issue is this?

  • Question. Is this a question about how to do a certain thing? - Yes

We are trying to specify format in ApiParam. We see that it supports the field. When swagger is generated, the format field is not present.

@ApiParam(
    value = "Example: 12345678-1234-1234-1234-123456789012", 
    required = true, 
    allowEmptyValue = false, 
    format = "testFormat")
@Size(min=36, max=36)
@RequestParam(value = "correlationID") String correlationID)

generates

{
    name: "correlationID",
    in: "query",
    description: "Example: 12345678-1234-1234-1234-123456789012",
    required: true,
    type: "string",
    maximum: 36,
    minimum: 36,
}

We also want to add custom formats to ApiModelProperty, but it does not appear to support the format field. Is that a potential feature that can be added, or is there a work-around for this?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
stale[bot]commented, Jun 24, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

0reactions
Rajan2212commented, Nov 27, 2020

How to add below lines in the json file using swagger annotation ? which annotation should be used ?

{ “type”: “string”, “format”: “password” }

I am not able to get proper answer till now…is only by manual way we can achieved this ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swagger @ApiParam vs @ApiModelProperty - Baeldung
The @ApiParam annotation is for the parameters of an API resource request, whereas @ApiModelProperty is for properties of the model.
Read more >
Use @ApiParam or @ApiModelProperty in swagger?
They are both used to add metadata to swagger but they add different metadata. @ApiParam is for parameters. It is usually defined in...
Read more >
ApiImplicitParam (swagger-annotations 1.5.12 API)
While ApiParam is bound to a JAX-RS parameter, method or field, this allows you to manually define a ... Adds the ability to...
Read more >
Types and Parameters - OpenAPI - Documentation | NestJS
Types and parameters. The SwaggerModule searches for all @Body() , @Query() , and @Param() decorators in route handlers to generate the API document....
Read more >
Springfox Reference Documentation - GitHub Pages
Import the bean in your xml configuration by defining a bean of the ... ApiModelProperty#dataType we can override the inferred data types.
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