influxdata / influxdata/oats

Limited requestBody content types supported

Open
#16 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
14
Forks
5
Avg merge
3d 8h
Merged PRs (30d)
1

Description

given the following section of a swagger file:
```yml
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. (/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:
```js
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
```yml
- in: header
name: Content-Type
schema:
type: string
enum:
- application/vnd.influxql
```

Contributor guide

Open the contributing guide

Research direction

Start with generate.js lines 89-92 in collectBodyParam and reproduce generation using the shown application/vnd.influxql requestBody schema. Compare the failure with the text/plain and Content-Type header workaround. Done means the custom media type no longer produces the reported TypeError and the generator behavior is verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.