Swagger Codegen for Eiffel

by javier (modified: 2018 Jun 14)

Swagger Codegen for Eiffel

What’s Swagger RESTful API Documentation Specification?

The Swagger specification (lately renamed as OpenAPI Specification) offers a language-agnostic approach for describing RESTful APIs.

In a few words it provides:

  • API Design: A simple and powerful representation for your APIs.
  • API Consumer: An automated way to generate API clients for third-party RESTful APIs using Swagger specification.
  • API Producer: An automated way to generate server stubs from an API specification.

What’s Swagger code generator?

It’s an Open-source project which allows generation of API client libraries (SDK generation), server stubs and documentation automatically given an OpenAPI Spec.At the moment we only have support for API client code generator.

Getting Started with Swagger code generator

First, check the following document to get started with Swagger code generator.

Generating Client Side Code

One of the main advantages of Swagger code generator to wrap API clients is that it reduces the time to write glue code and API documentation. Swagger code generator enables us to automate this process using a language agnostic approach.

Generating Eiffel API clients

To generate a client API in Eiffel, the command line tool swagger-codegen is used as follows: Here we will describe the options we are using to run the command.

-i <spec file> | --input-spec <spec file> -l <language> | --lang <language> -o <output directory> | --output <output directory

To learn more about the command line tool options check the following section

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i http://petstore.swagger.io/v2/swagger.json -l eiffel -o samples/client/petstore/eiffelThis will generate a full API client library and test cases which we will be able to use in other projects. To generate the code, Swagger Codegen uses a template-based engine that parses specification files to generate documentation and API clients.

Using the generated library

To use the generated code include the library api_client.ecf in your project.


If you want to collaborate and contribute to improve the Eiffel Swagger code generator, please read the following document.