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

Comments

Projects
None yet
3 participants
@justcoon

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 the question label Sep 17, 2016

@dilipkrish dilipkrish added this to the 2.6.0 milestone Sep 17, 2016

@dilipkrish

This comment has been minimized.

Member

dilipkrish commented Sep 17, 2016

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 added feature and removed question labels Sep 17, 2016

@dilipkrish dilipkrish modified the milestones: 2.7.0, 2.6.0 Sep 17, 2016

@dilipkrish dilipkrish changed the title from RequestBody model problem if interface only with getters is used to Infer alternate type rules using serializers and deserializers Sep 17, 2016

@kinbiko

This comment has been minimized.

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

This comment has been minimized.

Member

dilipkrish commented Jan 16, 2017

@kinbiko answered in SO.

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