ESI Swagger Codegen Issues and Workarounds
This blog addresses an inconsistency [1] with a tool used within our previous blog: Using Swagger Codegen to Generate a Client API.
In the previous blog we chronicled how to generate an ESI client library for Python using the Swagger Editor or curling the https://generate.swagger.io endpoint (which the Swagger Editor uses). However, it's been brought to our attention that https://generate.swagger.io is not working with the ESI Swagger spec found at https://esi.tech.ccp.is/_latest/swagger.json.
Because online Swagger tools may not always work, this blog will present a backup method that can be used to generate a client library from ESI's Swagger spec.
Prerequisites
For this specific workaround you will need Docker installed on your machine. We will not go into detail about what Docker is or how it works but feel free to dig into Docker's documentation.
Generating a Python Client Library Using Docker
After installing Docker, run the following command:
docker run --rm -v ${PWD}:/local swaggerapi/swagger-codegen-cli generate -i "https://esi.tech.ccp.is/_latest/swagger.json" -l python -o /local/python-client
which will produce a directory called python-client
with the client library inside. python-client
will be situated wherever the docker command was run.
What this command is doing is pulling Swagger's Docker image called swaggerapi/swagger-codegen-cli
, running the image inside a Docker container and then deleting that container once it is done.
In Unix based systems, generating the python-client may create some permission problems when trying to follow the directions for using the library in our previous blog. For good measure, run the following command on the python-client
directory:
sudo chown -R $USER python-client
Generating a Python Client Library Without Docker
Instructions for building and running the swagger-codegen-cli outside of Docker can be found on the swagger/swagger-codegen Github page.
[1] Somewhere around July 14th, 2017 the code behind https://generator.swagger.io was updated with Swagger codegen version 2.2.3. This version of the Swagger codegen has a bug in its parser that is making the generator not work for the ESI Swagger spec. According to a Swagger dev their online tools will be updated end of August 2017 with Swagger codegen 2.3.0 which is the version that comes with the Docker image used in this blog.
o7
- CCP Zoetrope