vndbre / vndbre-proxy

https://vndbre-proxy.herokuapp.com/swagger
MIT License
0 stars 0 forks source link

RFC: Stabilize v1 API for vndb query proxy response #3

Closed prekel closed 3 years ago

prekel commented 3 years ago

Vndb query can return different responses:

  1. results {...json...} (https://vndb.org/d11#5)
  2. error {...json...} (https://vndb.org/d11#7)
  3. ok (https://vndb.org/d11#3) (will not be used by frontend in normal use)

This kinds of responses must be mapped to one API response. But, there 2 another cases:

  1. Unknown response - nor 1, 2, 3. Then, we can provide raw unparsed response.
  2. Internal error. Then, we provide error message

This 5 cases can be mapped with 2 ways.

First:

  1. Status200OK
    {
    "response": "results",
    "data": {...json...}
    }
  2. Status400BadRequest
    {
    "response": "error",
    "data": {...json...}
    }
  3. Status200OK
    {
    "response": "ok"
    }
  4. Status501NotImplemented
    {
    "response": "unknown",
    "raw": "string with raw response"
    }
  5. Status500InternalServerError
    {
    "response": "internalerror",
    "error": "error message"
    }

Second:

  1. Status200OK
    {
    "response": "results",
    "data": {...json...}
    }
  2. Status400BadRequest
    {
    "response": "error",
    "data": {...json...}
    }
  3. Status200OK
    {
    "response": "ok",
    "data": null
    }
  4. Status501NotImplemented
    {
    "response": "unknown",
    "data": "string with raw response"
    }
  5. Status500InternalServerError
    {
    "response": "internalerror",
    "data": "error message"
    }

Which is better: first or second? @Moltenship @NightOfNights @choi-moeta

moetazaneta commented 3 years ago

For ok we should probably use 204 status code without data (https://restfulapi.net/http-status-codes/).

panov-aleksey-saritasa commented 3 years ago

Don't see much difference, but second is more neat to me.

prekel commented 3 years ago

Done.

https://github.com/vndbre/vndbre-proxy/blob/master/VndbReProxy.Api/Requests/api.http

Where host is https://vndbre-proxy.azurewebsites.net/

image

prekel commented 3 years ago

Ok, second