Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support server variables #222

Merged
merged 16 commits into from Mar 6, 2021
Merged

Conversation

rwalle61
Copy link
Collaborator

For #89

Supercedes #161 and #218. Thanks @JonnySpruce for your work on this!

I think I've overcomplicated your code in order to output these error messages. Perhaps we can simplify it in future :)

@codecov
Copy link

codecov bot commented Feb 28, 2021

Codecov Report

Merging #222 (9941c32) into master (39c5d60) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #222   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           16        17    +1     
  Lines          373       400   +27     
  Branches        49        56    +7     
=========================================
+ Hits           373       400   +27     
Impacted Files Coverage Δ
...enapi-validator/lib/classes/AbstractOpenApiSpec.js 100.00% <100.00%> (ø)
.../openapi-validator/lib/classes/AbstractResponse.js 100.00% <100.00%> (ø)
...ages/openapi-validator/lib/classes/OpenApi2Spec.js 100.00% <100.00%> (ø)
...ages/openapi-validator/lib/classes/OpenApi3Spec.js 100.00% <100.00%> (ø)
...penapi-validator/lib/classes/SuperAgentResponse.js 100.00% <100.00%> (ø)
...ckages/openapi-validator/lib/openApiSpecFactory.js 100.00% <100.00%> (ø)
.../openapi-validator/lib/utils/OpenApi3Spec.utils.js 100.00% <100.00%> (ø)
...ckages/openapi-validator/lib/utils/common.utils.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 39c5d60...9941c32. Read the comment docs.

@rwalle61
Copy link
Collaborator Author

So I wasn't aware that Travis recently changed their pricing plan such that open source projects no longer have a generous allowance of builds. We seem to have very quickly used up our one-off allowance. Following their FAQ, I've requested more build minutes - hopefully they'll be generous.

If not, we'll have to migrate to another build provider, perhaps GitHub Actions, though I haven't looked into it yet

Copy link
Collaborator Author

@rwalle61 rwalle61 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good for merging and publishing after CI is fixed and I've corrected the two test names

Object.entries(serverVariables).reduce(
(currentMap, [variableName, detailsOfPossibleValues]) => ({
...currentMap,
[variableName]: getPossibleValuesOfServerVariable(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: we use variableName here but variable on line 39. I think by definition a variable is a variableName, but in the openapi spec a server variable is a complex object. This is an example of how migrating our code to TypeScript in future will hopefully help clarify it

@@ -0,0 +1,91 @@
const generateCombinations = require('combos');
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file could definitely be simpler, but I'm not sure how. Will be very grateful for suggestions! The tricky thing is to provide error messages with server urls that are templated before the path, and concrete after the path, e.g. https://{hostVariable}.com:{portVariable}/defaultValueOfVariableInPath (See the tests)

rwalle61 added a commit that referenced this pull request Mar 6, 2021
Migrating away from Travis CI because we [no longer get free builds :(](#222 (comment))
@rwalle61 rwalle61 merged commit 2938997 into master Mar 6, 2021
@rwalle61 rwalle61 deleted the 89-add-server-variable-support branch March 6, 2021 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants