@JsonUnwrappred is ignored by Schema generation

See original GitHub issue

This issue is a copy of https://github.com/springfox/springfox/issues/192

@JsonUnwrappred jackson annotation is ignored by schema generation.

springfox version 2.6.1

@RequestMapping(value = "1740", method = RequestMethod.GET)
public Bug1740 bugNNN() {
  return new Bug1740();
}

public class Bug1740 {
  private String value;

  @JsonUnwrapped
  private Bug1740Inner inner;

  public String getValue() {
    return value;
  }

  public Bug1740Inner getInner() {
    return inner;
  }

  private final class Bug1740Inner {
    private String innerValue;

    public String getInnerValue() {
      return innerValue;
    }
  }
}

Actual schema generated:

"Bug1740": {
  "type": "object",
  "properties": {
    "inner": {
      "$ref": "#/definitions/Bug1740Inner"
    },
    "value": {
      "type": "string"
    }
  }
},
"Bug1740Inner": {
  "type": "object",
  "properties": {
    "innerValue": {
      "type": "string"
    }
  }
}

Expected schema:

"Bug1740": {
  "type": "object",
  "properties": {
    "value": {
      "type": "string"
    },
    "innerValue": {
      "type": "string"
    }
  }
}

PR with test https://github.com/springfox/springfox/pull/1741

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
troybartlettcommented, Apr 21, 2017

Would love to get this fix in a release… any idea when that might happen?

0reactions
davidbilgecommented, Jan 30, 2019

Can anyone confirm that this is actually fixed? I am on 2.9.2 and @JsonUnwrapped is still only considered if the annotation is placed on the getter. If I annotate a field, it does not appear.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JsonUnwrapped is ignored when visiting serializers ... - GitHub
@JsonUnwrapped is ignored when visiting serializers for schema ... the "old" schema generation part; and handle new one on schema module.
Read more >
How to ignore specific sub-field of an unwrapped field (CSV)
Use: @JsonIgnoreProperties({ "toBeIgnoredA", "toBeIgnoredB" }) public class ToSerialize { @JsonUnwrapped(prefix = "toBeUnwrapped") ...
Read more >
JSON Schema Support using Jackson in Java? - Tutorialspoint
The JsonSchema can define validation, documentation, hyperlink navigation, and interaction control of JSON data. We can generate the JSON schema ...
Read more >
Jackson JSON - Using @JsonUnwrapped to serialize ...
JsonUnwrapped is used to indicate that a property should be serialized unwrapped, i.e. the target property will not be serialized as JSON ...
Read more >
JsonUnwrapped (The Adobe AEM Quickstart and Web ...
... com.adobe.xmp.schema.model.rules · com.adobe.xmp.schema.rng.model ... be altered regardless of inclusion strategy; so annotation is basically ignored.
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