Skip to content

Releases: influxdata/oats

v0.7.0

15 Sep 16:32
Compare
Choose a tag to compare

v0.7.0

Adds the following new options to the command line:

  -V, --version                output the version number
  -i, --include <parts>        include only specified code parts (default: "types,request,operations")
  -p, --prettier [true/false]  prettier output code (default: true)
  --withDoc [true/false]       document generated types (default: true)
  --patchScript <file>         apply script that modifies openapi document (example: https://github.com/influxdata/influxdb-client-js/blob/master/packages/apis/scripts/patchSwagger.js)
  --storeOperations <file>     store operations to file
  -h, --help                   output usage information

Contribution courtesy of @sranka #8

v0.5.0

14 Oct 21:26
Compare
Choose a tag to compare

Add pre-request and post-response functionality hooks

Adds the ability to modify the request or response by creating a request handler function or response handler function.

type RequestHandler = (
  url: string,
  query: string,
  init: RequestInit // this represents the second parameter passed to `fetch`
) => {url: string, query: string, init: RequestInit}

type ResponseHandler = (
  status: number,
  headers: Headers,
  data: any
) => {status: number, headers: Headers, data: any}

These hooks are added by the following function calls:

setRequestHandler: (requestHandler: RequestHandler) => void

setResponseHandler: (responseHandler: ResponseHandler) => void

An example of it in action:

import {setRequestHandler, setResponseHandler} from '/location-of-routes'

setRequestHandler((url, query, init) => {
  if (init.method === 'put') {
    init.method = 'patch'
  }
  return {url, query, init}
})

setResponseHandler((status, headers, data) => {
  if (status === 404) {
    window.location.href = '/adorable-404-page'
  }

  return {status, headers, data}
})