Skip to content

Commit

Permalink
document common params
Browse files Browse the repository at this point in the history
  • Loading branch information
Reuven committed Feb 4, 2024
1 parent 853e35f commit a78ad13
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
36 changes: 36 additions & 0 deletions COMMON-PARAMS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Common Parameters

### Common Parameters Definition
Parameters shared by all operations of a path can be defined on the path level instead of the operation level.
Path-level parameters are inherited by all operations of that path.
A typical use case are the GET/PUT/PATCH/DELETE operations that manipulate a resource accessed via a path parameter.

### There are two ways to handle Common Parameters in oasdiff
1. By default, oasdiff compares path parameters and operation parameters seperately.
2. The `--flatten-params` merges common parameters from the path level into the operation level before running the diff.

For example, this command outputs two breaking changes:
```
oasdiff changelog data/common-params/params_in_path.yaml data/common-params/params_in_op.yaml
```
Output:
```
2 changes: 2 error, 0 warning, 0 info
error [new-request-path-parameter] at data/common-params/params_in_op.yaml
in API GET /admin/v0/abc/{id}
added the new path request parameter 'id'
error [new-required-request-parameter] at data/common-params/params_in_op.yaml
in API GET /admin/v0/abc/{id}
added the new required 'header' request parameter 'tenant-id'
```


Adding the `--flatten-params` eliminates the errors:
```
oasdiff changelog data/common-params/params_in_path.yaml data/common-params/params_in_op.yaml --flatten-params
```




2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ docker run --rm -t tufin/oasdiff changelog https://raw.githubusercontent.com/Tuf
- [API deprecation](API-DEPRECATION.md)
- [Multiple versions of the same endpoint](MATCHING-ENDPOINTS.md)
- [Merge allOf schemas](ALLOF.md)
- [Common Parameters](ALLOF.md)
- [Merge common parameters](COMMON-PARAMS.md)
- [Path prefix modification](#path-prefix-modification)
- [Path parameter renaming](#path-parameter-renaming)
- [Excluding certain kinds of changes](#excluding-specific-kinds-of-changes)
Expand Down

0 comments on commit a78ad13

Please sign in to comment.