apiaryio / api-blueprint

API Blueprint
https://apiblueprint.org
MIT License
8.63k stars 2.14k forks source link

Generate response body from Attributes when content type is application/vnd.api+json #433

Closed alangibson-philips closed 5 years ago

alangibson-philips commented 5 years ago

[EDIT] It works as expected when you actually use the right mime type. It's "application/vnd.api+json" not "application/vnd.json+api". Although, the mock server responds with "content-type: application/json", so it might be getting it right by accident.

[EDIT2] And the content-type is suddenly correct. May be experiencing some lag between the editor and the mock server.


Is there any way to get Apiary to generate response body from Response Attributes when content type is application/vnd.api+json?

Apairy never generates a response body with the following definition, neither in the documentation nor in the mock server. It works fine with Response 200 (application/json).

## Profile Singleton [/Profile/self]

### Get own Profile [GET]

- Request
  - Headers
    Accept: application/vnd.json+api
    Accept-Language: en_US
    api-version: 1.0.0
    Authorization: Bearer JWT
    ```

Data Structures

Profile

ProfileResponse

ProfileResource

It seems to have worked in these cases: https://github.com/apiaryio/api-blueprint/issues/195 https://github.com/apiaryio/api-blueprint/issues/380

kylef commented 5 years ago

Glad you figured it out.

[EDIT2] And the content-type is suddenly correct. May be experiencing some lag between the editor and the mock server.

Remember to save your document before using the mock server. Since you can use the mock server from the console in the live preview it could be out of sync and be a little confusing. The mock server only goes by the saved state.