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

Infer alternate type rules using serializers and deserializers #1490

Closed
justcoon opened this issue Sep 15, 2016 · 3 comments
Closed

Infer alternate type rules using serializers and deserializers #1490

justcoon opened this issue Sep 15, 2016 · 3 comments
Labels
Milestone

Comments

@justcoon
Copy link

justcoon commented Sep 15, 2016

if in request body is used interface, only with getters, with custom serialization and deserialization

@Value.Immutable 
@JsonSerialize(as =  ImmutableCreateRoleCommand.class)
@JsonDeserialize(as = ImmutableCreateRoleCommand.class)
public interface CreateRoleCommand  {
 String getAggregateId();
 String getName();
}

@RestController
public class RoleController {

    @ApiOperation(httpMethod = "POST", value = "create role", response = RoleAggregate.class)
    @RequestMapping(path =  "/role/create", method = RequestMethod.POST)
    RoleAggregate createRole(@RequestBody CreateRoleCommand command) {
       ...
    }
}

model is not detected correctly

swagger_requestbody_model_problem

problem is probably in implementation of

springfox.documentation.schema.property.OptimizedModelPropertiesProvider

method: BeanDescription beanDescription(ResolvedType type, ModelContext context)
@dilipkrish dilipkrish added this to the 2.6.0 milestone Sep 17, 2016
@dilipkrish
Copy link
Member

Create an alternate type rule to map CreateRoleCommand.class to ImmutableCreateRoleCommand.class. Springfox cannot infer serializers, may be it should but as of now its not supported. So you need to assist it by telling it what your object looks like.

@dilipkrish dilipkrish modified the milestones: 2.7.0, 2.6.0 Sep 17, 2016
@dilipkrish dilipkrish changed the title RequestBody model problem if interface only with getters is used Infer alternate type rules using serializers and deserializers Sep 17, 2016
@kinbiko
Copy link

kinbiko commented Jan 16, 2017

As a followup to this feature request, could someone take a look at this link and let me know if it's the same problem? I'm finding it a bit hard to read from context. If so, could you also elaborate on "Create an alternate type rule to map A to B" in the previous comment? I'm struggling to find documentation on how to do this.
Thank you.

@dilipkrish
Copy link
Member

@kinbiko answered in SO.

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

No branches or pull requests

3 participants