Skip to content

Paths with multiple results ignored #11

Open
@miroslav-mastny-regosys

Description

@miroslav-mastny-regosys

Endpoints with multiple results are ignored and appropriate code is not generated. No (reason/warning) message is showed, it's very confusing.

Nice solution is used by nswag. For response 200 generate correct result (function result type) and typed exception for others (any exception with json object is welcomed).

------------ sample: json multiple responses ----------------

    "responses": {
      "200": {
        "description": "OK result - array of type 'Source' instances",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Sources"
            }
          }
        }
      },
      "default": {
        "description": "Processing error (unexpected)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Errors"
            }
          }
        }
      }
    }

------------- sample: nswag implementation -----------------

  ProcessResponse(client_, response_);

  var status_ = (int)response_.StatusCode;
  if (status_ == 200)
  {
      var objectResponse_ = await ReadObjectResponseAsync<System.Collections.Generic.ICollection<Source>>(response_, headers_, cancellationToken).ConfigureAwait(false);
      if (objectResponse_.Object == null)
      {
          throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
      }
      return objectResponse_.Object;
  }
  else
  {
      var objectResponse_ = await ReadObjectResponseAsync<System.Collections.Generic.ICollection<Error>>(response_, headers_, cancellationToken).ConfigureAwait(false);
      if (objectResponse_.Object == null)
      {
          throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
      }
      throw new ApiException<System.Collections.Generic.ICollection<Error>>("Processing error (unexpected)", status_, objectResponse_.Text, headers_, objectResponse_.Object, null);
  }

---------- the end -----------------------

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