Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@ApiImplicitParam does not accept primitives or "string" as valid dataType values #3520

Open
samuelbchase opened this issue Aug 27, 2020 · 3 comments
Milestone

Comments

@samuelbchase
Copy link

samuelbchase commented Aug 27, 2020

Hi! I'm having an issue with @ApiImplicitParam in version 3.0.0.

When we define an ApiImplicitParam like so:

@ApiImplicitParam(name = ID_HEADER, paramType = "header", required = true, dataType = "string", defaultValue = ID_HEADER_DEFAULT, value = ID_HEADER_DESC)
the generated JSON does not contain the type or the defaultValue. Inside the console I see Unable to interpret the implicit parameter configuration with dataType: "string", which makes sense, as in OperationImplicitParameterReader L173 an exception is thrown, as "string" is indeed not a valid class. This also occurs when I try a primitive type, like "int"

The Bug is that this behaviour was valid before 3.0.0, so ideally it'd be great if we could add that functionality back. It looks like this functionality was re-added in commit 3cd0f7c, but I'm having trouble building locally to validate

The workaround is to just use dataTypeClass, with value String.class, as this executes OperationImplicitParameterReader L171, circumventing the problem. But ideally, it'd be great if the previously exisiting functionality could be brought back

Workaround example: @ApiImplicitParam(name = ID_HEADER, paramType = "header", required = true, dataTypeClass = String.class, defaultValue = ID_HEADER_DEFAULT, value = ID_HEADER_DESC)

I had considered creating a quick code contribution to fix this issue, but then I saw you appear to have fixed it in 3cd0f7c. If that doesn't work, I could make a PR updating the modelSpecification() method to allow param.dataType() to allow the values of "string", and all privitive types.

Thanks!

Additional Info:

Maven imports:
~/fakepath » mvn clean dependency:tree | grep springfox
[INFO] | +- io.springfox:springfox-swagger2:jar:3.0.0:compile
[INFO] | | +- io.springfox:springfox-spi:jar:3.0.0:compile
[INFO] | | | \- io.springfox:springfox-core:jar:3.0.0:compile
[INFO] | | +- io.springfox:springfox-schema:jar:3.0.0:compile
[INFO] | | +- io.springfox:springfox-swagger-common:jar:3.0.0:compile
[INFO] | | +- io.springfox:springfox-spring-web:jar:3.0.0:compile
[INFO] | | +- io.springfox:springfox-spring-webmvc:jar:3.0.0:compile
[INFO] | | +- io.springfox:springfox-spring-webflux:jar:3.0.0:compile

@samuelbchase samuelbchase changed the title @ApiImplicitParam does not accept primatives or "string" as valid dataType values @ApiImplicitParam does not accept primitives or "string" as valid dataType values Aug 28, 2020
@dilipkrish dilipkrish added this to the 3.0.1 milestone Sep 5, 2020
@dilipkrish
Copy link
Member

Please use dataTypeClass instead to see if that fixes your problem. I'll clarify the docs and make this experience better in the next patch.

@samuelbchase
Copy link
Author

Sure, thanks! dataTypeClass does in this case work, I wasn't sure if the feature deprecation was intention.

@Gerado-Ahumada
Copy link

I had a same problem, thanks!!!! 🫡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants