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

When a payload has fields with mixed presence documenting those fields may still result in a failure due to undocumented fields #626

Open
wilkinsona opened this issue Jun 20, 2019 · 0 comments

Comments

@wilkinsona
Copy link
Member

Taken from this question on Stack Overflow, consider the following JSON payload:

{
  "count": 2,
  "items": [
    {
      "k1": "v1",
      "k2": []
    },
    {
      "k1": "v2",
      "k2": [
        {
          "name": "joe"
        },
        {
          "name": "alice"
        }
      ]
    }
  ]
}

Documenting the following fields should be sufficient for the payload to be considered fully documented:

  • count
  • items[].k1
  • items[].k2[].name

Instead, REST Docs reports that items[].k2 has not been documented.

When items[].k2[].name is documented, it's removed from its containing object. The object then becomes empty and it's removed from its parent array. This parent array, items[].k2 then becomes empty so it is removed from items. This only works for the second items[].k2 entry in the payload. The first items[].k2 entry is unaffected because it's empty to begin with. As a result, there's no removal of the name entry to trigger the cascading removal of empty containers (objects or arrays).

@wilkinsona wilkinsona added this to the 2.0.4.RELEASE milestone Jun 20, 2019
@wilkinsona wilkinsona self-assigned this Jun 20, 2019
@wilkinsona wilkinsona modified the milestones: 2.0.4.RELEASE, 2.1.0.RC1 Sep 18, 2019
@wilkinsona wilkinsona removed this from the 2.1.0-RC1 milestone Mar 24, 2022
@wilkinsona wilkinsona removed their assignment Oct 12, 2022
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

1 participant