Skip to content

Support derived types in request body #110

@Ultre00

Description

@Ultre00

When I use the following json:

"/api/app/customer": {
      "post": {
        "tags": [
          "Customer"
        ],
        "operationId": "CreateAsync",
        "requestBody": {
          "content": {
            "application/json-patch+json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/CreateUpdateCompanyDto"
                  },
                  {
                    "$ref": "#/components/schemas/CreateUpdateContactDto"
                  }
                ],
                "nullable": true
              }
            },
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/CreateUpdateCompanyDto"
                  },
                  {
                    "$ref": "#/components/schemas/CreateUpdateContactDto"
                  }
                ],
                "nullable": true
              }
            },
            "text/json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/CreateUpdateCompanyDto"
                  },
                  {
                    "$ref": "#/components/schemas/CreateUpdateContactDto"
                  }
                ],
                "nullable": true
              }
            },
            "application/*+json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/CreateUpdateCompanyDto"
                  },
                  {
                    "$ref": "#/components/schemas/CreateUpdateContactDto"
                  }
                ],
                "nullable": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerDto"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerDto"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerDto"
                }
              }
            }
          }
        }
      },

The generated code has an empty request body:

static createAsync(options: IRequestOptions = {}): Promise<CustomerDto> {
    return new Promise((resolve, reject) => {
      let url = '/api/app/customer';

      const configs: IRequestConfig = getConfigs('post', 'application/json', url, options);

      let data = null;

      configs.data = data;
      axios(configs, resolve, reject);
    });
  }

Is it possible to add support for derived types, or is it already supported and I am missing something here ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    not activeClose up for a long time is not active Issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions