-1

I am working on swagger document, and want to customize the example model in POST request. This request takes a JSON body, which has certain parameters. I want to remove some parameters and and set default values for others. What annotations should i use and where??

Currently the default body shows as

[
  {
    "height": 0,
    "day": 0,
    "decimalYear": 0,
    "fyear": 0,
    "elevation": 0,
    "azimuth": 0,
    "month": 0,
    "year": 0
  }
]

I want the body to be as

[{
    "elevation": 28,
    "azimuth": -61, 
    "height": 81555, 
    "year": 1965, 
    "month": 11,
    "day":8
}]
Swarit Agarwal
  • 2,520
  • 1
  • 26
  • 33
NTarun
  • 1
  • 1

2 Answers2

1

To add default value you can use @RequestParam(defaultValue = "sample") and for optional prams use @RequestParam(required = false) documentation

  • Thanks Diyananda, but its not a single parameter value, i need to customize it in JSON body, that i don't know how to do, single parameters, i can edit, i need to customize the input example model – NTarun Feb 05 '20 at 09:26
-1

Welcome to stack overflow.

I believe you should go for API Operation and follow as mentioned in link

https://github.com/swagger-api/swagger-core/wiki/Annotations

You can manipulate values as per your need, Annotation needs to use at controller layer

Swarit Agarwal
  • 2,520
  • 1
  • 26
  • 33
  • Thanks Swarit for your quick response, this i have already tried but its not working, i need to customize the JSON body of the POST request, which it is taking by default and assigns default value of zero to all the fields, also it takes some unnecessary fields which i need to remove from th e request body – NTarun Feb 05 '20 at 08:55