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

Including request body XML in output documentation #16

Open
DavidOliver opened this issue Jun 23, 2017 · 4 comments
Open

Including request body XML in output documentation #16

DavidOliver opened this issue Jun 23, 2017 · 4 comments

Comments

@DavidOliver
Copy link

My test:

  test "creates support_request and returns support_request ID when data is valid", %{conn: conn} do
    body = ~s(<?xml version="1.0" encoding="utf-8"?>
      <data>
        <SamplerID>#{@create_attrs.sampler_id}</SamplerID>
        <SupportRequest>
          <ContactName>#{@create_attrs.contact_name}</ContactName>
          <ContactEmail>#{@create_attrs.contact_email}</ContactEmail>
          <Title>#{@create_attrs.title}</Title>
          <Details>#{@create_attrs.details}</Details>
        </SupportRequest>
      </data>
    )
    conn = conn
    |> put_req_header("user-agent", @create_attrs.user_agent)
    |> put_req_header("content-type", "application/xml")
    |> post(support_request_path(conn, :create), body)
    |> BlueBird.ConnLogger.save()

    # assert that text the length of a UUID forms the response body
    assert text_response(conn, 200) |> String.length == 36
  end

The resultant Body in the Request in the output documentation:

{"aspect":"body_params"}

Is it possible to have the request body XML included? Thanks.

@woylie
Copy link
Member

woylie commented Jun 23, 2017

Hi David,

right now, BlueBird is only able to handle json and plain text bodies correctly. We're going to add support for other content types in the future, but I can't give you a time frame yet.

@DavidOliver
Copy link
Author

Okay - thanks for the info.

@DavidOliver
Copy link
Author

I'm thinking about getting round it for now by manually putting the request body XML in the description; see screenshot:

screenshot from 2017-06-24 15-53-27

The main issue with this workaround is that the incorrect request body is present in the right-hand column. Any ideas on hiding it? If this isn't possible I may switch to writing out the API Blueprint "design" manually for projects which use XML, but I thought I'd ask here first. :) Many thanks.

@woylie
Copy link
Member

woylie commented Jun 24, 2017

I don't have a quick fix for this. What we could do in a future version is to check the request content-type header before adding it to the documentation.

One difficulty in general is that you can only read the request body from the conn once. So as soon as a plug reads the body, we can't access it with BlueBird anymore. We'll have to put in some thought to figure out how to handle request bodies in a nice way.

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

3 participants