Manfred / Reynard

Minimal OpenAPI client for Ruby.
MIT License
12 stars 2 forks source link

Implement tools for filtering and combining OpenAPI specs #40

Open Manfred opened 1 year ago

Manfred commented 1 year ago

When projects publish their endpoint specs in an extremely large file or in lots of smaller files you may want to massage them a little bit and only take the parts that you actually use. The idea is that Reynard can help with this because it already has an interface to navigate the specs.

For example:

# Filter based on operation names
reynard reduce --source https://example.com/openapi.json --select-operations getAuthors,getAuthor,getLibrary > openapi.yml
# Filter using a configuration file
reynard reduce --source https://example.com/openapi.json --select-file config/used.yml --format json > openapi.json
# Combine multiple sources
reynard combine --source openapi1.json --source openapi2.json > openapi.yml

It may be useful to keep a cached version of the sources and use conditional requests to speed up interaction. We should also fall back on a cached versions when an HTTP request fails with a server error.

Manfred commented 3 months ago

There are some optional operations that could be interesting for these tools:

  1. Move all external references into the components sections of the specification so they are contained in a single file.
  2. De-duplicate parts of the specification.
  3. Remove all optional parts that are not used for actual operation so reduce the memory footprint (eg. all example properties).