This directory hosts The Generator, a tool that generates the classes for each API endpoint from the Elasticsearch REST API JSON Specification.
To generate the code, you need to run (from this folder):
$ thor code:generate
- The Ruby code will be generated in
elasticsearch-api/lib/elasticsearch/api/actions
. - The generator runs Rubocop to autolint and clean up the generated files.
The main entry point is generate_source.rb
, which contains a class that implements a Thor task: generate
:
$ thor api:code:generate
It uses Thor::Actions' template
method and templates/method.erb
to generate the final code. The generator
directory contains some helpers used to generate the code. The ERB template is split into partials and you can find all ERB files in the templates
directory.
There's also a lister task:
$ thor api:list
It's implemented in lister.rb
and it lists all the REST API endpoints from the JSON specification.