LiveRamp / reslang

A language for describing resource-oriented APIs & turning them into Swagger or resource diagrams. Oriented around the concepts we want to expose in the APIs.
Apache License 2.0
23 stars 7 forks source link

Support HTTP Request Headers #164

Closed njaczko closed 3 years ago

njaczko commented 3 years ago

Jira: https://liveramp.atlassian.net/browse/API-415

The feature added by this PR is described here: https://github.com/LiveRamp/reslang/blob/support-http-headers/docs/reference.md#http-request-headers

I'm definitely open to suggestions for better solutions to the problem I described in this comment: https://github.com/LiveRamp/reslang/blob/support-http-headers/src/genswagger.ts#L33-L48 I think the implementaion I went with is pretty simple and adds the fewest conditionals, but it might not be elegant or intuitive :/

Unfortunately, the order in which the addHeaderParams function and the formIdOperations/formNonIdOperations functions are called matters, but they could be implemented in such a way that the order doesn't matter. To do so would require many changes inside formIdOperations and formNonIdOperations which are incredibly complex and have effectively no test coverage. I felt like the risk of introducing bugs and effort of making the changes was not worth it. I documented all this in the code: https://github.com/LiveRamp/reslang/blob/support-http-headers/src/genswagger.ts#L201 https://github.com/LiveRamp/reslang/blob/support-http-headers/src/genswagger.ts#L242

If CJ merges his open PR first I will change the Reslang version bump in this PR accordingly (or we can bundle them into one release)

Will resolve https://github.com/LiveRamp/reslang/issues/159

ops-github-DU4JOAWE commented 3 years ago

This change is Reviewable

njaczko commented 3 years ago

Bonus in this PR: updated the grammar so the /events, /operations, and /request-headers sections can be included in any order!