ttu / dotnet-fake-json-server

Fake JSON Server is a Fake REST API that can be used as a Back End for prototyping or as a template for a CRUD Back End.
https://ttu.github.io/dotnet-fake-json-server/
MIT License
388 stars 84 forks source link

Bad XML tags occuring when getting single family #64

Closed herariom closed 5 years ago

herariom commented 5 years ago

When using the command "curl -H "Accept: text/xml" http://localhost:57602/api/families/1", it appears that an errant \<friends />" tag (not \</friends>) appears right before a \</child> tag.

      </friends>
    </child>
    <child>
      <name>Katheryn</name>
      <gender>female</gender>
      <age>9</age>
      <friends />
    </child>
  </children>

For the command "curl -H "Accept: text/xml" http://localhost:57602/api/families/0", an errant \<children /> tag occurs after \</parents>

    </parent>
  </parents>
  <children />
  <address>
    <postNumber>147</postNumber>
    <street>Melba Court</street>

I did some testing and was able to replicate this problem before the changes in XML pluralization, but I wasn't able to find an immediate cause.

ttu commented 5 years ago

Thanks for the issue!

I think this works correctly. <friends /> is a self closing element. Same as it would be <friends></friends>.

Child in family 1 has an empty array in friends (also family 0 has an empty array in children). XML serializer will just create an empty element for empty arrays.

        {
          "name": "Katheryn",
          "gender": "female",
          "age": 9,
          "friends": []
        }

If you think this should work differently, just reopen this issue.