# OpenAPI to Typescript Interfaces

crdtotypes is a tool that creates Typespcript interfaces from [OpenAPI](https://www.openapis.org/) definition files.

## Usage

Use OpenAPI file to create typescript interfaces.

``` bash
npm install --location=global crdtoapi

# add npm bin path to your PATH, or use full
# excutable path, e.g. $(npm bin --location=global)/crdtoapi
crdtotypes --help

# create typescript interface files in ./tmp dir
mkdir tmp
crdtotypes -i openapi.yaml -o ./tmp --out ./tmp
```

The tool will add the `IoK8sApimachineryPkgApisMetaV1ObjectMeta` definition file, and an `index` file to the output direcotry.

Example of generated interface file.

``` ts
/**
 * Forklift API
 * Migration toolkit for virtualization (Forklift) API definitions.
 *
 * The version of the OpenAPI document: 2.4.0
 * Contact Email: kubev2v-dev@redhat.com
 * License: Apache-2.0
 *
 * NOTE: This file is auto generated by crdtotypes (https://github.com/yaacov/crdtoapi/).
 * https://github.com/yaacov/crdtoapi/README.crdtotypes
 */

import { IoK8sApimachineryPkgApisMetaV1ObjectMeta } from './IoK8sApimachineryPkgApisMetaV1ObjectMeta';
import { V1beta1HookSpec } from './V1beta1HookSpec';
import { V1beta1HookStatus } from './V1beta1HookStatus';

/**
 * Hook is the Schema for the hooks API
 *
 * @export
 */
export interface V1beta1Hook {
  /** apiVersion
   * APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
   *
   * @required {true}
   */
  apiVersion: string;
  /** kind
   * Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
   *
   * @required {true}
   */
  kind: string;
  /** metadata
   *
   * @required {false}
   * @originalType {V1beta1HookMetadata}
   */
  metadata?: IoK8sApimachineryPkgApisMetaV1ObjectMeta;
  /** spec
   * Hook specification.
   *
   * @required {false}
   */
  spec?: V1beta1HookSpec;
  /** status
   * Hook status.
   *
   * @required {false}
   */
  status?: V1beta1HookStatus;
}

```
