redocly-cli icon indicating copy to clipboard operation
redocly-cli copied to clipboard

fix: join paths properly

Open roman-sainchuk opened this issue 3 years ago • 4 comments

What/Why/How?

Currently summary, description, servers, parameters fields are ignored/incorrectly handled by join command.

This PR is rework for join command based on this one. The reason is that changes in the latest is based just on checking if the value of PathItem field is of object type. I suppose that current logic performed on object values is making sense only for Operation Object type. summary, description, servers and parameters should be joined in a different way.

Things required to finish this PR:

  • [x] Merge only operations (post, get, etc.) using existing implementation
  • [ ] Implement join of Operation Objects which are $refs
  • [ ] Implement join of summary and description
  • [ ] Implement join of servers
  • [ ] Implement join of parameters
  • [ ] Add meaningful tests for join command

Reference

Testing

Screenshots (optional)

Check yourself

  • [x] Code is linted
  • [ ] Tested with redoc/reference-docs/workflows
  • [ ] All new/updated code is covered with tests

Security

  • [ ] Security impact of change has been considered
  • [ ] Code follows company security practices and guidelines

roman-sainchuk avatar Jul 27 '22 08:07 roman-sainchuk

Coverage report

St.:grey_question:
Category Percentage Covered / Total
🟡 Statements
72.23% (+3.31% 🔼)
3103/4296
🟡 Branches
64.15% (+2% 🔼)
1680/2619
🟡 Functions
63.91% (+3.35% 🔼)
503/787
🟡 Lines
72.22% (+3.45% 🔼)
2885/3995
Show files with reduced coverage 🔻
St.:grey_question:
File Statements Branches Functions Lines
🟢 cli/src/js-utils.ts
90.91% (-9.09% 🔻)
83.33% (-16.67% 🔻)
100% 100%

Test suite run success

475 tests passing in 81 suites.

Report generated by 🧪jest coverage report action from 7f0a4e46d98b66feff7348d278b49ecd82073483

github-actions[bot] avatar Jul 27 '22 08:07 github-actions[bot]

For description and summary - take it from first document For servers - create unique array by url from both documents

@adamaltman @RomanHotsiy please advice how to join parameters ? Should we create unique array by name and in fields ?

roman-sainchuk avatar Aug 01 '22 11:08 roman-sainchuk

Can you exclude prettier changes from this PR? It's hard to review :(

removed

roman-sainchuk avatar Aug 01 '22 13:08 roman-sainchuk

For description and summary - take it from first document

Yes, I would also show a warning if there are different values and they mismatch.

For servers - create unique array by url from both documents

Yes. I would also show a warning or even crash if there are different values and they mismatch (e.g. variables)

how to join parameters ? Should we create unique array by name and in fields ?

Yes. Unique by name/in seems valid. Make sure to crash if there are different schemas. For different descriptions we can show warnings only.

RomanHotsiy avatar Aug 01 '22 14:08 RomanHotsiy

LGTM 👍

roman-sainchuk avatar Aug 23 '22 14:08 roman-sainchuk