Skip to content

Limited requestBody content types supported #16

@glinton

Description

@glinton

given the following section of a swagger file:

      requestBody:
        description: InfluxQL query to execute.
        content:
          application/vnd.influxql:
            schema:
              type: string

I get the following error when generating a client:

(node:67136) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '0' of undefined
    at Generator.collectBodyParam (/go/src/github.com/influxdata/influxdb/ui/node_modules/@influxdata/oats/dist/generate.js:91:65)
    at Generator.registerPathOperation (/go/src/github.com/influxdata/influxdb/ui/node_modules/@influxdata/oats/dist/generate.js:40:29)
    at new Generator (/go/src/github.com/influxdata/influxdb/ui/node_modules/@influxdata/oats/dist/generate.js:24:26)
    at generate (/go/src/github.com/influxdata/influxdb/ui/node_modules/@influxdata/oats/dist/generate.js:219:23)
    at async Command.<anonymous> (/go/src/github.com/influxdata/influxdb/ui/node_modules/@influxdata/oats/bin/oats:7:18)
(node:67136) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:67136) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

lines 89-92 of generate.js are as follows:

        const fallbackEntry = mediaTypeEntries[0];
        if (fallbackEntry) {
            return { description, required, mediaType: textEntry[0], type: "any" };
        }

The resolution was to change the content from application/vnd.influxql to text/plain and add a header parameter

        - in: header
          name: Content-Type
          schema:
            type: string
            enum:
              - application/vnd.influxql

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