-
Notifications
You must be signed in to change notification settings - Fork 1
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
[WIP] Fix api blueprint format #1
Conversation
- Headers and Body sections were indented with 8 spaces instead of 12 (https://github.com/apiaryio/api-blueprint/blob/format-1A/API%20Blueprint%20Specification.md#ActionResponseSection) - The API name was not present (https://github.com/apiaryio/api-blueprint/blob/format-1A/API%20Blueprint%20Specification.md#42-api-name--overview-section)
- Path segments extensions were not following the RFC 6570
- Remove Content-Type header from the Header sections
- Switch from path segment expansion to simple string expansion because the former is not supported by Apiary
I had to switch from path segment expansion to simple string expansion for the URLs because the former is not supported by Apiary. FTR here's a file generated with the modified version of the gem. |
I couldn’t figure out how to fix the attribute thing. If I had to guess I’d say that it’s around RspecApiDocumentation::DSL::Resource.attribute and RspecApiDocumentation::DSL::Endpoint::Params#call but I’m not sure. |
More API Blueprint fixes
I'm keeping this PR inside the FinalCAD organization for now because it's not completely ready yet and I'll add comments related to
Finalcloud
.Feel free to make a PR against https://github.com/zipmark/rspec_api_documentation when it'll be finished.
The goal of this PR is to fix the
rspec_api_documentation
gem regarding the generation of documentation targeting the API Blueprint format.Apiary was used to spot the errors in the generated file.
The API Blueprint Language Specification is available here. I targeted format 1A.
Here's what was fixed so far:
Some errors remain when we generate documentation with these fixes:
Both are warnings. The second one is more important than the first one because the parameters are not correctly described.
The "duplicate definition" one shouldn't be too complicated. It occurs because the media type is defined both in the Resource Model Section and in the Headers. For example:(Fixed in b57259d)rspec_api_documentation
, query parameters are described by using theparameter
method, be it an url parameter (for exampleid
in/users/:id
) or a parameter sent in the request body.But for the API Blueprint format, there's a distinction. URL parameters are described with the
parameter
method but body parameters are described using theattribute
method.If we use the
parameter
method to describe an attribute, we have a warning because we describe a parameter which is not present in the URL.This means that in our spec on
finalcloud
, we'll have to change all the description of attributes using theparameter
method and replace it by theattribute
one (there's no difference between both methods signatures so we'll just have to replace it where we need and keepparameter
when it's an URL parameter).The problem in the gem is that it only sends parameters described with the
parameter
method and not the other ones.The following code will work and send
{"team": {"id": "d2988ee2-23b1-4573-8724-e2e8b94b8c84"}}
in the body.But if we replace
parameter
byattribute
, the body will be empty.To fix this, we'll need to allow attributes to be added to the body when they're defined with the
attribute
method. We might also need to consider them as parameters in the other formats, otherwise they might not be displayed.