Skip to content

Swagger model building from POJO does not take into account "custom" Jackson serialization config #4173

Open
@bushwakko

Description

@bushwakko

Wrote description of problem here: zalando/problem#319 (comment)

This is because the implementation used by the problem-detail library, has StatusType in the POJO, and registers a Jackson-Module to the ObjectMapper, that provides code to serialize the StatusType class to ensure the serialized output is an integer. The code that builds the model in Swagger (ModelResolver), however, tries to makes its own interpretation of the Problem class. Since the Module contains serialization code, and not any declarative config/metadata, it doesn't take into account how that object is serialized by Jackson's ObjectMapper.

I'm not sure what the solution is though, other than it needs to take into account all the information Jackson has.

It would have to analyze the Jackson-configuration, find which classes are serialized differently, and account for that in the model. Alternatively, the ModelResolver could instead populate and serialize a dummy object, analyze the resulting json and try to make a model based on that, or at least see where the json differs from its current model.

Edit: The ModelResolver method "resolve()" that does the interpretation, is 750 (!) lines long, and thus very hard to understand.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions