Skip to content

Commit

Permalink
Keep only listed root resources (#271)
Browse files Browse the repository at this point in the history
* Suppress deep paths to unkept types
* Stub references with anonymous object
* Bump version and dependencies
* Also keep contained entities
* Keep types of contained entities
* Keep entity types contained in kept entity types
* Keep function import and its parameters and return types
* Ignore bound overloads for keeping return types
* Bound actions and functions
* Extract and test cli argument parsing
  • Loading branch information
ralfhandl authored Feb 1, 2024
1 parent c365051 commit e0dedbc
Show file tree
Hide file tree
Showing 10 changed files with 1,024 additions and 121 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## [0.25.0] - 2024-01-12

### Added

- Command-line option `--keep` (short `-k`) to specify which root resources (entity sets, singletons, action imports, function imports) to keep.
- Paths for the root resources are kept, as are paths to contained entities and bound actions and functions.
- Types referenced by the (return) type of root resources via structural properties or containment navigation properties are also kept.
- Non-containment navigation properties to entity types not kept are changed to use a generic stub object type without properties.
- Deep paths to stubbed entity types are omitted.
- The `/$batch` resource is omitted.

## [0.24.2] - 2024-01-16

### Fixed
Expand Down
1 change: 1 addition & 0 deletions lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Options:
-d, --diagram include YUML diagram
-h, --help show this info
--host host (default: localhost)
-k, --keep root resource to keep (can be specified multiple times with one name each)
--levels maximum number of path segments
-o, --openapi-version 3.0.0 to 3.0.3 or 3.1.0 (default: 3.0.2)
-p, --pretty pretty-print JSON result
Expand Down
7 changes: 7 additions & 0 deletions lib/cliParts.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function parseArgs(argv) {
-d, --diagram include YUML diagram
-h, --help show this info
--host host (default: localhost)
-k, --keep root resource to keep (can be specified multiple times with one name each)
--levels maximum number of path segments
-o, --openapi-version 3.0.0 to 3.0.3 or 3.1.0 (default: 3.0.2)
-p, --pretty pretty-print JSON result
Expand All @@ -30,6 +31,7 @@ function parseArgs(argv) {
"basePath",
"description",
"host",
"keep",
"levels",
"openapi-version",
"scheme",
Expand All @@ -40,6 +42,7 @@ function parseArgs(argv) {
alias: {
d: "diagram",
h: "help",
k: "keep",
o: "openapi-version",
p: "pretty",
t: "target",
Expand Down Expand Up @@ -77,6 +80,10 @@ function parseArgs(argv) {
case "description":
options.defaultDescription = value;
break;
case "keep":
if (Array.isArray(value)) options.rootResourcesToKeep = value;
else options.rootResourcesToKeep = [value];
break;
case "levels": {
const l = Number(value);
if (!isNaN(l)) options.maxLevels = l;
Expand Down
Loading

0 comments on commit e0dedbc

Please sign in to comment.