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

Support default status codes #105

Closed
ritch opened this issue Jul 1, 2015 · 2 comments
Closed

Support default status codes #105

ritch opened this issue Jul 1, 2015 · 2 comments
Assignees
Labels

Comments

@ritch
Copy link
Member

ritch commented Jul 1, 2015

The generated swagger spec should include status codes sourced from the sharedMethod.http.status / sharedMethod.http.errorStatus, see strongloop/strong-remoting#218.

Although I'm not sure how the mapping should look exactly...

@ritch ritch self-assigned this Jul 1, 2015
@bajtos
Copy link
Member

bajtos commented Sep 8, 2015

👍

@bajtos bajtos mentioned this issue Sep 8, 2015
12 tasks
@bajtos bajtos assigned 0candy and unassigned ritch Dec 10, 2015
@bajtos bajtos added the #plan label Dec 10, 2015
@bajtos
Copy link
Member

bajtos commented Dec 15, 2015

@0candy The goal of this task is to add support for the new feature landed by strongloop/strong-remoting#218:

In short, method's http object supports two new config options status and errorStatus, see this example:

{
  isStatic: true,
  accepts: [],
  returns: [],
  http: {
    status: 201,
    errorStatus: 508 
  }
}

When set, the values override the default success status code (200) and the default error status code (500).

The current implementation in loopback-swagger uses hard-coded 200, see https://github.com/strongloop/loopback-swagger/blob/9a30a143a47445f321c1d349c5b808517e248686/lib/specgen/route-helper.js#L126-L127

var defaultCode = route.returns && route.returns.length ? 200 : 204;
// TODO - support strong-remoting's option for a custom response code
var responseMessages = {};
responseMessages[defaultCode] = {
  description: 'Request was successful',
  schema: returns,
  // TODO - headers, examples
};

There is no default error status described, I think we should add one if the list of know error does not cover it. See https://github.com/strongloop/loopback-swagger/blob/9a30a143a47445f321c1d349c5b808517e248686/lib/specgen/route-helper.js#L136-L147:

if (route.errors) {
  // TODO define new LDL syntax that is status-code-indexed
  // and which allow users to specify headers & examples
  route.errors.forEach(function(msg) {
    responseMessages[msg.code] = {
      description: msg.message,
      schema: schemaBuilder.buildFromLoopBackType(msg.responseModel,
                                                  typeRegistry),
      // TODO - headers, examples
    };
  });
}

@bajtos bajtos added #tob and removed #plan labels Dec 15, 2015
@bajtos bajtos added #plan and removed #tob labels Jan 7, 2016
@0candy 0candy added #tob and removed #plan labels Jan 12, 2016
@0candy 0candy added #plan and removed #tob labels Mar 22, 2016
@bajtos bajtos added #sprint6 and removed #plan labels Mar 22, 2016
@0candy 0candy self-assigned this Mar 31, 2016
@0candy 0candy added #review and removed #wip labels Apr 4, 2016
@0candy 0candy closed this as completed Jul 14, 2016
@0candy 0candy removed the #tbr label Jul 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants