open-match icon indicating copy to clipboard operation
open-match copied to clipboard

openapi spec for must return nullable typed for 200 in /v1/queryservice/tickets:query

Open dzmitry-lahoda opened this issue 3 years ago • 6 comments

Steps:

  1. https://storage.googleapis.com/open-match-chart/api/v0.0.0-dev/query.swagger.json
  2. Generate client from it by some tool which adheres to OpenApi spec

Expected:

  • When there are no tickets, all is ok

Actual:

  • Generated client throws exception about null return

Fix:

  • make types nullables if they are such ("x-nullable")

Next fix works with client generator(

    "/v1/queryservice/tickets:query": {
      "post": {
        "summary": "QueryTickets gets a list of Tickets that match all Filters of the input Pool.\n  - If the Pool contains no Filters, QueryTickets will return all Tickets in the state storage.\nQueryTickets pages the Tickets by `queryPageSize` and stream back responses.\n  - queryPageSize is default to 1000 if not set, and has a minimum of 10 and maximum of 10000.",
        "operationId": "QueryService_QueryTickets",
        "responses": {
          "200": {
            "x-nullable": true,
            "description": "A successful response.(streaming responses)",
            "schema": {
              "type": "object",                         
              "properties": {
                "result": {
                  "$ref": "#/definitions/openmatchQueryTicketsResponse"
                },
                "error": {

Notes

I think other methods should be patches either

dzmitry-lahoda avatar Jul 22 '21 09:07 dzmitry-lahoda

Hi @dzmitry-lahoda - thanks for the issue. Can you expand on what you mean by

I think other methods should be patches either a little bit so we can better understand this part of the issue? Thanks!

joeholley avatar Sep 01 '21 12:09 joeholley

I think other methods should be patches either

@joeholley I believe this was saying there way be other methods that throw exceptions in the case where having no results is acceptable such as no assignments, no tickets, etc. @dzmitry-lahoda correct me if I am wrong

@dzmitry-lahoda I believe this is fine but may you submit a PR with all of the method which this fix may apply to as well?

syntxerror avatar Aug 02 '22 15:08 syntxerror

is not json generated from proto? I was thinkin it should be done there, just sent patch to check if json are generated or manual. so these are manual and need to be kept in sync?

dzmitry-lahoda avatar Aug 02 '22 18:08 dzmitry-lahoda

@dzmitry-lahoda, Would you like to submit PR for this change ? We would like to review it.

mridulji avatar Aug 16 '22 15:08 mridulji

Hi @dzmitry-lahoda, swagger.json files are auto generated from this command api/%.swagger.json inside makefile. Thanks!

ashutosji avatar Mar 06 '23 16:03 ashutosji

We investigated this but didn't find a workable way to generate swagger with the x-nullable attrib from protobufs. If you have a working implementation feel free to submit a PR and we'll be happy to review it.

joeholley avatar Mar 16 '23 01:03 joeholley