Skip to content

ccouzens/vcloud-rest-openapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VMware Cloud Director Rest OpenAPI definitions

OpenAPI definitions for vCloud's Rest API.

These can be used to generate libraries for interacting with vCloud from any mainstream programming langauge.

OpenAPI definitions are sometimes known by their previous name of Swagger specifications.

vCloud Director 10.2.2 Rest API

Other versions: see top level folder

In general, clients can be generated by running an openapi-generator command similar to:

openapi-generator generate -i 'https://raw.githubusercontent.com/ccouzens/vcloud-rest-openapi/main/35.2.json' -g 'typescript-axios' -o 'src/vcloud-client'

Background

This is a repository of OpenAPI definitions for vCloud's Rest API. They are automatically generated from the public documentation to reduce human error, reduce human effort and to make it easy to stay up-to date.

vCloud Director has an official OpenAPI, but it contains little of the functionality of the Rest API.

Some of the documentation instructs the user to follow link attributes in the responses and not to create hrefs manually. This is incompatible with OpenAPI and contradicts other official documentation that lists out paths within the API. This definition uses predefined paths.

How the definitions are generated

VMware Cloud Director Rest API supports responses and requests as both JSON and XML. But only XML is officially documented by VMWare. JSON is better suited for OpenAPI and modern usage. The mapping from XML to JSON is predictable.

Types are documented by VMware in XSD (XML Schema Definition). XSD is a complicated format. It supports lots of concepts and it has multiple ways of expressing a single concept. There are edge cases where I've not yet incorporated an XSD concept.

Each API version has a zip file containing documentation about it on the vmware website. The zip file is downloaded and passed into a Rust program that extracts various information like responses, requests and paths. This program then generates a JSON OpenAPI definition.

If you find an issue, tell me about it using Github and I shall try and address it.

License

The transformer (code that does the converting of the published documentation to OpenAPI) is MIT Licensed.

I've assigned the copyright of the OpenAPI definitions to VMware as they are derived from their documentation.

Differences between versions

It may be useful to see what has changed between two versions. The key to getting a useful diff is to mask the version number in the content header. The following command lines are useful for seeing the differences between versions:

# If the repository is downloaded
diff -U20 --color=always \
  <(< 36.0.json sed -r 's/version=[0-9.]+/version=xx.x/') \
  <(< 36.3.json sed -r 's/version=[0-9.]+/version=xx.x/') \
  | less -R
# If the repository has not been downloaded
diff -U20 --color=always \
  <(
    curl -s https://raw.githubusercontent.com/ccouzens/vcloud-rest-openapi/main/36.0.json \
    | sed -r 's/version=[0-9.]+/version=xx.x/'
  ) \
  <(
    curl -s https://raw.githubusercontent.com/ccouzens/vcloud-rest-openapi/main/36.3.json \
    | sed -r 's/version=[0-9.]+/version=xx.x/'
  ) \
  | less -R

Known Issues

Unable to compile Java openapi client#3

The temporary workaround:

  1. Copy patch scripts fix-vcd-type-discriminator_01.sed and fix-vcd-type-discriminator_02.sed to the root project directory

  2. Clean up the codegenerated client :

  rm -rf <output directory>
  1. Run the script from the root project directory:
find ./<output directory> -regex '.*\(Type\|Value\)\.java' -exec grep -H 'String JSON_PROPERTY_TYPE = "_type"' {} \; -exec sed -ri -f ./fix-vcd-type-discriminator_01.sed {} \; && find ./<output directory>/ -regex '.*\(Type\|Value\)\.java' -exec grep -H 'extends .*\(Type\|Value\)' {} \; -exec sed -ri -f ./fix-vcd-type-discriminator_02.sed {} \;