influxdata / influxdata/oats

Oats requires the server directive

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

Description

A swagger definition is valid without this directive, but oats requires it.

Given the following swagger:
```yaml
openapi: "3.0.0"
info:
title: Stuff service
version: 0.0.0
paths:
/stuff:
post:
operationId: createStuff
requestBody:
description: thing
content:
application/json:
schema:
type: string
responses:
'204':
description: No content
```

Oats returns the following error:
```
/src/node_modules/@influxdata/oats/dist/generate.js:32
server: this.doc.servers[0].url,
^

TypeError: Cannot read property '0' of undefined
at Generator.registerPathOperation (/src/node_modules/@influxdata/oats/dist/generate.js:32:37)
at new Generator (/src/node_modules/@influxdata/oats/dist/generate.js:24:26)
at generate (/src/node_modules/@influxdata/oats/dist/generate.js:219:23)
at async Command. (/src/node_modules/@influxdata/oats/bin/oats:7:18)
```

Run with:
```sh
docker run -v ${PWD}:/test --entrypoint /src/node_modules/.bin/oats quay.io/influxdb/oats /test/swagger.yaml
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with the provided Docker command and swagger definition, then inspect dist/generate.js, especially registerPathOperation, and the bin/oats entry point. Done means this valid OpenAPI definition runs without the TypeError when no servers directive is present.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.