Skip to content

GoDaddy improvements - round 2 - #61

Merged
bajtos merged 7 commits into
masterfrom
feature/godaddy-improvements-round-2
Oct 16, 2014
Merged

GoDaddy improvements - round 2#61
bajtos merged 7 commits into
masterfrom
feature/godaddy-improvements-round-2

Conversation

@bajtos

@bajtos bajtos commented Oct 14, 2014

Copy link
Copy Markdown
Member

Another follow-up pull request for #52.

  • swagger: use X-Forwarded-Host for basePath
  • swagger: Deprecate opts.swaggerVersion
  • loopbackStyles: improve spacing in small window
  • swagger: include models from accepts/returns args
  • route-helper: add responseMessages

Requires strongloop/strong-remoting#113 (/cc @ritch)

/to @raymondfeng and/or @STRML please review
/cc @shelbys

@bajtos bajtos added the #review label Oct 14, 2014
@shelbys shelbys mentioned this pull request Oct 14, 2014
7 tasks
@bajtos bajtos changed the title Godaddy improvements - round 2 GoDaddy improvements - round 2 Oct 14, 2014
@bajtos

bajtos commented Oct 14, 2014

Copy link
Copy Markdown
Member Author

A note on response messages - copied from #52.

Swagger provides two ways for specifying the response type:

  1. globally in operations[].type
  2. per-response-code in responseMessages[].responseModel

screen shot 2014-10-14 at 13 36 43

In the screenshot above, operations[].type is displayed as "Response Class" at the top, responseMessages[].responseModel is displayed in "Response Model" inside "Response Messages" section at the bottom.

I am proposing to include the response model in both places for now. We can later add a configuration option to customise this behaviour, if such thing is requested.

@bajtos

bajtos commented Oct 14, 2014

Copy link
Copy Markdown
Member Author

The CI builds will be failing until strongloop/strong-remoting#113 is released in 1.x, since that's the version used by explorer.

@bajtos
bajtos force-pushed the feature/godaddy-improvements-round-2 branch from 818abb4 to 9b21f40 Compare October 14, 2014 16:50
@bajtos

bajtos commented Oct 14, 2014

Copy link
Copy Markdown
Member Author

Rebased on top of the current master, which uses loopback@2.x for running the tests.

@shelbys

shelbys commented Oct 15, 2014

Copy link
Copy Markdown
Contributor

@bajtos - We switched to always using responseMessage.responseModel, because we use different Models by Status, including a custom, reusable Model for Error responses. This is more natural for many of our endpoints that aren't CRUD-related. Also, I believe it better uses the space visually and with less confusion.

You could change it to use type if there aren't multiple possible, but we'd never use that since we always have multiple

For reference, see: https://developer.godaddy.com/doc#!/shoppers/Subaccount_create

@bajtos

bajtos commented Oct 15, 2014

Copy link
Copy Markdown
Member Author

I believe it better uses the space visually and with less confusion.

Agreed.

@raymondfeng @ritch do you have any opinion on this? I am inclined to rework the implementation and drop route-level response type as originally proposed in #52.

The only issue I am aware of is that the user cannot select response type (json, xml, etc.), as the combo-box is gone. It looks like a swagger ui bug to me though.

screen shot 2014-10-15 at 10 18 47

@shelbys

shelbys commented Oct 15, 2014

Copy link
Copy Markdown
Contributor

@bajtos - I have also moved the Response Content Type select to down by the "Try it out!" In shelbys/swagger-UI

@bajtos

bajtos commented Oct 16, 2014

Copy link
Copy Markdown
Member Author

@bajtos - I have also moved the Response Content Type select to down by the "Try it out!" In shelbys/swagger-UI

That makes a lot of sense to me, it is one more reason to upstream your changes.

Miroslav Bajtoš added 6 commits October 16, 2014 10:34
Users of loopback-explorer should not override the swagger version,
as it's the explorer who decides what version of the Swagger Spec
it implements.
Improve spacing of page elements when the browser window is small.
Models not attached to the app are included too.
Accepts/returns arguments allow anonymous object types, e.g.

    { 'arg': 'kvp', type: { 'name': 'string', 'value': 'string' } }

As of this commit, these types are converted to Swagger type 'object'.
Add a default "success" response message, the status code is 200 or 204
depending on whether the method returns any data.

Append any error messages as specified in the `errors` property
of method's remoting metadata.

Move the description of operation's return type to the "success"
response message.

Include error message models in the API models.
@bajtos
bajtos force-pushed the feature/godaddy-improvements-round-2 branch from 9b21f40 to d05dcb7 Compare October 16, 2014 12:04
@slnode

slnode commented Oct 16, 2014

Copy link
Copy Markdown

Test FAILed.

1 similar comment
@slnode

slnode commented Oct 16, 2014

Copy link
Copy Markdown

Test FAILed.

Add tests verifying that Swagger docs include model description for
recursively nested references to Models and Arrays of Models in
properties, modelTo and modelThrough relations, accepts,
returns and errors.

Fix bugs discovered along the way.
@bajtos
bajtos force-pushed the feature/godaddy-improvements-round-2 branch from fa3f822 to 6fb81c2 Compare October 16, 2014 12:44
@bajtos

bajtos commented Oct 16, 2014

Copy link
Copy Markdown
Member Author

I have rebased the patch on top of the current master and modified the responseMessages implementation to drop route-level response type in favour of response-message type.

@shelbys Please confirm that master handles all of: 1) recursively nested references to 2) Models and 3) Arrays of Models in 4) properties, 5) modelTo and modelThrough relations, 6) accepts, 7) returns and 8) errors

I have added integration tests for that in the last commit and fixed bugs discovered along the way.

@raymondfeng please review.

@slnode

slnode commented Oct 16, 2014

Copy link
Copy Markdown

Test FAILed.

@bajtos

bajtos commented Oct 16, 2014

Copy link
Copy Markdown
Member Author

@slnode test please

@slnode

slnode commented Oct 16, 2014

Copy link
Copy Markdown

Test PASSed.

@raymondfeng

Copy link
Copy Markdown
Member

LGTM

bajtos added a commit that referenced this pull request Oct 16, 2014
@bajtos
bajtos merged commit 5308083 into master Oct 16, 2014
@bajtos bajtos removed the #review label Oct 16, 2014
@bajtos
bajtos deleted the feature/godaddy-improvements-round-2 branch October 16, 2014 16:59
@STRML

STRML commented Nov 10, 2014

Copy link
Copy Markdown
Member

From discussion on swagger-spec, it appears type is the correct usage in 1.2. This changes in 2.0. We should be compliant with the spec. I'll send in a PR that references this issue.

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

Successfully merging this pull request may close these issues.

5 participants