eqx-gin-server

module
v0.2.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2022 License: MIT

README

Golang client for Equinix Metal

This is experimental. Don't use it in production. Examples demonstrate that this client is usable. Please submit patches and open issues with your experience.

This repo contains Golang code generated from customized spec.swagger.json from the Equinix Metal API from https://api.equinix.com/metal/v1/api-docs. The client is generated using the Go client support built into the OpenAPITools openapi-generator.

Contents:

  • Makefile includes tasks to fetch the API spec, apply patches, and generate a client
  • spec.fetched.json the latest fetched swagger spec
  • spec.patched.json the latest patched swagger spec
  • patches/spec.fetched.json/*.patch patch files to apply against the Equinix Metal API spec
  • patches/post/*.patch patch files to apply against the generated project
  • examples/ hand crafted examples to demonstrate usage
  • metal/v1/ generated client

Generated Client

See API.md

Build

To build the client, run make.

Examples

You can see usage of the generated code in the examples directory. In order to try, export METAL_AUTH_TOKEN token and execute the code, e.g.

Patches

Patches can be generated by modifying a prestine spec.fetched.json or spec.patched.json file and running:

git diff spec.fetched.json > patches/spec.fetched.json/01-name-of-patch.patch

Run make and git diff spec.patched.json to verify that the changes have persisted corrected.

The json code is very similar in areas. It may be necessary to include more context lines in the patch to prevent the patch from applying to the wrong endpoint or model.

git diff -U7, or greater -U values can be used to ensure that the adjacent endpoint or model is referenced in the patch file. This will ensure that the patch has not drifted to another resource due to other changes.

Duplicate Errors

The generator has problems handling multiple tags in operations. The generator will create duplicate types when it encounters this. Many of the needed patches remove the extra tags, usually choosing the most significant tag to keep, sometimes just choosing the first tag.

The following jq command can help to filter the extra tags out:

cat spec.patched.json  | jq '. | select(((.paths[][].tags| type=="array"), length) > 1).paths[][].tags |= [.[0]]' > /tmp/foo
mv /tmp/foo spec.patched.json
git diff -U7 spec.patched.json > patches/0x-more-tags.patch

See https://github.com/OpenAPITools/openapi-generator/issues/741 for the related bug.

Directories

Path Synopsis
examples
gin-server module
metal
v1

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL