#openapigenerator — Public Fediverse posts
Live and recent posts from across the Fediverse tagged #openapigenerator, aggregated by home.social.
-
So, in order to do the cleanups, I can use `yq`'s excellent filtering abilities. For example I have a list of verbatim API endpoints like `/token` and `/endpoint/{id}` in `allowed_apis.lst`:
```
yq '(load_str("allowed_apis.lst") | split("\n")) as $l | .paths |= with_entries(select(.key as $k | $l | any_c(. == $k)))' api.yaml > api_cleaned_paths.yaml
```And similar approach for models, except for `any_c(..)` I have to use `all_c(. != $k)`.
-
So, workflow is following:
0. Manually fix the OpenAPI `bundle.yaml` - this was actually something that caused the tool to exit with error...
1. Filter out unwanted APIs with `yq`
2. Run the openapi-generator-cli validator to get the list of unused models/types
3. Use `sed` to parse the list of unused models/types
4. Use `yq` again to filter out the unneeded models.
5. Generate the "minimum" client and models :)