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

XML Output not valid if returned array is not encapsulated #97

Open
tyzoid opened this issue Jul 24, 2017 · 2 comments
Open

XML Output not valid if returned array is not encapsulated #97

tyzoid opened this issue Jul 24, 2017 · 2 comments
Labels
Milestone

Comments

@tyzoid
Copy link
Collaborator

tyzoid commented Jul 24, 2017

The output tends to generate a XML document with more than one root node if the return values are not carefully encapsulated to avoid this.

One potential solution could be to detect the presence of multiple elements in the root array, and use a wrapping element to wrap them.

For comparison/testing, here is one such test case:
Controller:

class EmptyTest {
    /**
     * @name EmptyTest
     * @description Returns a bunch of empty/null values
     *
     * @url GET /empty
     */
    public function emptyTest() {
        return array(
            'message' => 'Hello World!',
            'test' => 0,
            'test2' => "0",
            'test3' => false,
            'text' => null,
            'string' => array(),
            'texts' => null,
            'strings' => array(),
            'arrs' => array('hi', 'hi2')
        );
    }
}

JSON:

{
    "message":"Hello World!",
    "test":0,
    "test2":"0",
    "test3":false,
    "text":null,
    "string":[],
    "texts":null,
    "strings":[],
    "arrs":[
        "hi",
        "hi2"
    ]
}

XML:

<?xml version="1.0"?>
<message>Hello World!</message>
<test>0</test>
<test2>0</test2>
<test3></test3>
<text></text>
<string></string>
<texts></texts>
<strings></strings>
<arrs>
    <arr>hi</arr>
    <arr>hi2</arr>
</arrs>
@tyzoid tyzoid added the Bug label Jul 24, 2017
@tyzoid tyzoid added this to the 1.2.0 Release milestone Jul 24, 2017
@tyzoid
Copy link
Collaborator Author

tyzoid commented Oct 22, 2017

Solution: Write a few generic API Response wrapper objects, which would allow correct exporting of both json, and xml.

Now to write it up.

@tyzoid
Copy link
Collaborator Author

tyzoid commented Nov 26, 2017

Moving to version 1.3.0

@tyzoid tyzoid modified the milestones: 1.2.0 Release, 1.3.0 Release Nov 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant