influxdata / oats

An OpenAPI to TypeScript generator.
MIT License
13 stars 6 forks source link

Oats requires the server directive #26

Open glinton opened 3 years ago

glinton commented 3 years ago

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

Given the following swagger:

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.<anonymous> (/src/node_modules/@influxdata/oats/bin/oats:7:18)

Run with:

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