Skip to content
This repository has been archived by the owner on Jan 3, 2022. It is now read-only.
/ openapi2crd Public archive

Generate Kubernetes Custom Resource Definition (CRD) resources from OpenAPI 3.0

License

Notifications You must be signed in to change notification settings

fybrik/openapi2crd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

❗ This project is no longer maintained

openapi2crd

Go Report Card Go Reference golangci-lint CodeQL gosec

openapi2crd is a CLI to generate Kubernetes Custom Resource Definition (CRD) resources from OpenAPI 3.0.

Install

Download the appropriate version for your platform from Releases. You may want to install the binary to somewhere in your system's PATH such as /usr/local/bin.

Alternatively, if you have go 1.16 or later then you can also use go install. This will put openapi2crd in $(go env GOPATH)/bin:

go install fybrik.io/openapi2crd@latest

Usage

  1. Create an OpenAPI 3.0 document with components.schemas (see example/spec.yaml)
    • The document must comply with the listed limitations
    • The document must include a component named the same as the kind you want to generate.
  2. Invoke openapi2crd command using one of the following methods:
    • Pass an input directory with CustomResourceDefinition resources lacking schema information (see example/input):
      openapi2crd SPEC_FILE --input INPUT_DIR --output OUTPUT_FILE
    • Pass the group version and kind of each CustomResourceDefinition you want to generate:
      openapi2crd SPEC_FILE --gvk GROUP/VERSION/KIND --output OUTPUT_FILE
    • A mix of the above is also valid

An output YAML file will be generated in the specified output location (see example/output/output.yaml)

Limitations

Only structural schemas are allowed with the following exceptions:

  1. You can use $ref as long as the referenced definition adheres to the listed limitations.
  2. You can use oneOf that contains just a list of $ref items. This is translated to an object with a string type field and an optional property for each $ref item.

Acknowledgements

The work is inspired by https://github.com/ant31/crd-validation and https://github.com/kubeflow/crd-validation.

About

Generate Kubernetes Custom Resource Definition (CRD) resources from OpenAPI 3.0

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •