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

Prefer Body attribute in request if provided #357

Open
jjatria opened this issue Aug 31, 2018 · 0 comments
Open

Prefer Body attribute in request if provided #357

jjatria opened this issue Aug 31, 2018 · 0 comments

Comments

@jjatria
Copy link

jjatria commented Aug 31, 2018

Take a simple document like this one:

FORMAT: 1A
HOST: https://cold.pizza

# Some API

# Root [POST /foo]

+ Request (application/xml)

    + Attributes (foo)

    + Body

            <?xml version="1.0" encoding="UTF-8"?>
            <foo>
                <bar>something</bar>
            </foo>

+ Response 200 (application/xml)

    + Attributes (result)

    + Body

            <?xml version="1.0" encoding="UTF-8"?>
            <result>
                <status>OK</status>
            </result>

## Data Structures

### `result`

- result (status, required)

### `status`

- status: OK (string, required)

### `foo`

- foo (required, bar)

### `bar`

- bar: woof (required, string)

When rendered using the default template (is this different with any others?) both the request and the response elements render the body as JSON instead of XML, even though the content-type header is correctly detected.

aglio_json_v_xml

Note also that the example string for the rendered body ("woof") is taken from the Data Structures section instead of the provided Body (in which case it would be "something").

I propose two changes to fix this:

  • Generate a request body from the attributes only when no Body has been provided already (we can assume that if the user provided one it's because they wanted it).

  • When generating a body, take into consideration what the content-type is for that request. There are probably too many to get it right, but we could definitely do better than forcing everything to use JSON no matter what.

Gasol added a commit to Gasol/aglio-theme-olio that referenced this issue Apr 20, 2019
Generate action body from the Attributes only when missing specified body

Resolve danielgtaylor/aglio#357
Gasol added a commit to Gasol/aglio-theme-olio that referenced this issue Apr 20, 2019
To resolve danielgtaylor/aglio#357, Generate action
body from the Attributes only when missing specified body.  line feed is need
to get rid of following message...

    ✗ #433: Line exceeds maximum allowed length. Length is 84, max is 80.
Gasol added a commit to Gasol/aglio-theme-olio that referenced this issue Apr 20, 2019
To resolve danielgtaylor/aglio#357, Generate action
body from the Attributes only when missing specified body.  line feed is need
to get rid of following message...

    ✗ #433: Line exceeds maximum allowed length. Length is 84, max is 80.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant