Skip to content

Plans to provide ResponseModel customization? #19

@UnoYakshi

Description

@UnoYakshi

Current ResponseModel provides 5 meta-fields:

{
  "data": {
    // Actual endpoint's response data...
  },
  "status": "SUCCESS",
  "message": "Hers's your user, pal!",
  "error_code": null,
  "description": "User found."
}

But, for example, I'd prefer to have:

for success

{
  "request_id": "UUID from service/proxy/gateway/etc.",
  "payload": {
    // Actual data...
  },
  "detail": "User [UUID] found.",  // Or even `null`?..
  "error": null
}

for failure

{
  "request_id": "UUID from service/proxy/gateway/etc.",
  "payload": null,
  "detail": "Could not retrieve a User [UUID] with such parameters...",
  "error": {
    "code": "VAL-422",
    "detail": [
      {
        "type": "int_parsing",
        "loc": [
          "query",
          "limit"
        ],
        "msg": "Input should be a valid integer, unable to parse string as an integer",
        "input": "dw"
      },
      {
        "type": "int_parsing",
        "loc": [
          "query",
          "itemsPerPage"
        ],
        "msg": "Input should be a valid integer, unable to parse string as an integer",
        "input": "pops"
      }
    ]
  }
}

Considering ResponseModel implementation, I see no way but to make a custom response schema + rewrite some inner logic (injection/rewriting). So I wonder if there are any plans on making customizable meta-fields: changing fields' names, adding new fields, hiding/removing old fields. If and only if it's possible, of course.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions