Sha256: 8908554708bc591fcd4cd1a0c1ef1cdda6249105ee10e7c8f26d3516c0357a49
Contents?: true
Size: 1.44 KB
Versions: 3
Compression:
Stored size: 1.44 KB
Contents
# Utils ## The Generator This directory hosts The Generator, a tool that generates the classes for each API endpoint from the [Elasticsearch REST API JSON Specification](https://github.com/elastic/elasticsearch/tree/master/rest-api-spec). ### Generate To generate the code, you need to have the Elasticsearch REST API spec files in `tmp/rest-api-spec` in the root of the project. You can run a rake task from the root of the project to download the specs corresponding to the current running cluster: ```bash $ rake elasticsearch:download_artifacts ``` Once the JSON files have been downloaded, you need to run (from this folder): ```bash $ 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. ### Development 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](https://github.com/erikhuda/thor/wiki/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.
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
elasticsearch-api-8.0.1 | utils/README.md |
elasticsearch-api-8.0.0 | utils/README.md |
elasticsearch-api-8.0.0.pre1 | utils/README.md |