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.

Incorrect input schema when multiple method params are used

See original GitHub issue

Describe the bug Generated schema includes all method parameters as “body” parameter, although it should include only @RequestBody parameter.

To Reproduce A simple rest controller with a single method: @RequestMapping(method = RequestMethod.POST) public ResultDto doSomething(Device device, @RequestBody @Valid SomeDto dto) Device is a bean parsed from a request by DeviceHandlerMethodArgumentResolver, but instead of Device, there can be any other dynamically injected types (like custom types related to security, etc).

Generated schema includes Device, although it shouldn’t, as only SomeDto is annotated with @RequestBody:

{
  "device": {
    "normal": true,
    "mobile": true,
    "tablet": true,
    "devicePlatform": "IOS"
  },
  "dto": {
    "foo": "string",
    "bar": "string"
  }
}

Expected behavior Generated schema should include only @RequestBody parameter.

I tried to check the documentation, but haven’t found anything related to this problem. Am I missing something?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
bnasslahsencommented, May 29, 2020

@ayzenquwe,

You can combine @ParameterObject Device device using v1.4.0.

@RequestMapping(method = RequestMethod.POST) public ResultDto doSomething(@ParameterObject Device device, @RequestBody @Valid SomeDto dto)

If it doesn’t answser your request. You can add more details about your expected OpenAPI genereated api-docs.

0reactions
ayzenquwecommented, May 30, 2020

I was talking about Spring @RequestBody, sorry for confusion. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

What's the best way to refactor a method that has too many (6+ ...
I would suggest trying "Introduce Parameter Object" first, and only fallback to the other options if you can't find a good parameter object...
Read more >
Should a method validate its parameters? [duplicate]
In general, I design my APIs as follows: 1. Document the methods well, and encourage the callers to pass good/valid data.
Read more >
Is it generally considered bad practice to use method input ...
Generally speaking, yes. "Side effects" like that are not obvious and can lead to bugs, devs usually expect input params to be unaltered....
Read more >
Fix Swagger Validator errors in Power Platform connectors
One of the body parameters in your swagger is using an invalid property that can't be used in a body parameter.
Read more >
SQLSTATE values and common error codes - Db2 - IBM
42878, An invalid function or procedure name was used with the EXTERNAL keyword. 42879, The data type of one or more input parameters...
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