Skip to content

type on operation object vs responseMessage.responseModel #197

Description

@STRML

When it comes to defining the return type of an operation, it appears that there are two valid ways to go.

The first is to define a type on the operation, e.g. like so:

{
  "path": "/user/login",
  "operations": [{
    "method": "POST",
    "nickname": "login",
    "parameters": [],
    "type": "User",
    "summary": "Log in."
  }]
}

The other is to define a responseModel as part of a responseMessage. This could be useful if multiple types of responses are possible. We discuss this in this loopback-explorer issue:

{
  "path": "/user/login",
  "operations": [{
    "method": "POST",
    "nickname": "login",
    "parameters": [],
    "responseMessages": [{
      "code": 200,
      "message": "Request was successful",
      "responseModel": "User"
    }],
    "summary": "Log in."
  }]
}

Which is the preferred style? If it is to use type, and to use responseMessages only for errors, could it be made more clear in the 1.2 spec that type is required?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions