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

Use definitionsFullyResolved to look up consumes/produces + tests #117

Merged
merged 7 commits into from
Dec 23, 2016

Conversation

lumaxis
Copy link
Contributor

@lumaxis lumaxis commented Dec 21, 2016

@whitlockjc This includes the changes from #101 plus I added tests.

For the tests, I basically duplicated the existing tests for operation.js but they are now run on both swagger.yaml and swagger-relative-refs.yaml.
Let me know if you'd prefer a different approach 👍

Closes #101, fixes #92

@lumaxis lumaxis force-pushed the definitionsFullyResolved branch from 8b6f9be to 6713ef2 Compare December 21, 2016 23:03
Copy link
Member

@whitlockjc whitlockjc left a comment

Choose a reason for hiding this comment

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

Can you answer the question and let me know?

@@ -64,6 +66,24 @@ module.exports.getSwaggerApi = function (callback) {
}
};

module.exports.getSwaggerApiRelativeRefs = function (callback) {
Copy link
Member

Choose a reason for hiding this comment

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

Where is this used? If it's unused, it should be removed from the PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I guess I hadn't scrolled down enough. I'll finish the review.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, GitHub hides the diff of that file by default, you have to explicitly load it 🙂
Also, just wanna let you know, that diff of that file looks way more complicated on GitHub than it actually is. It's really just copying all of the tests, indenting them one more level and changing them to use swagger-relative-refs.

@@ -32,260 +32,638 @@ var helpers = require('./helpers');
var Sway = helpers.getSway();

describe('Operation', function () {
var swaggerApi;
context('swaggerApiRelativeRefs', function () {
Copy link
Member

Choose a reason for hiding this comment

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

Any reason this is necessary? In previous tests where we use ./2.0/swagger-relative-refs.yaml we just do it in that specific test. Creating a SwaggerApi object using Sway#create with that file vs. using a helper is trivial so do we really need it?

(If we decide "No", we could remove the helper completely.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not strictly necessary but I added it because I had to supply jsonRefs manually to get the local refs parsed correctly.
Also, looking at the test you linked, I think this test is actually nor working. The result of Swagger.create appears to not be used at all and the test is really testing the object from line 39.

To sum it up, I'm happy to remove the helper but after considering the above, I'd suggest to use the helper in test-issues.js too.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, let's move it to test-issues.js and I'll merge it. Having a helper makes sense. Also, this is the only use of context as well so maybe we can do a per-test invocation of your helper?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@whitlockjc Okay, I fixed the test in test-issues.js but I'm not sure I understand your question about context. context is just an alias of describe and I used it to group the two test groups for the "regular" swaggerApi and one using relative refs. Could you clarify what you meant?

screen shot 2016-12-23 at 00 31 16

Copy link
Member

Choose a reason for hiding this comment

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

I just meant that for consistency, it might be best to use describe instead of context.

Also, what editor are you using?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is VS Code with an Atom theme 🙂
Sure, I can switch back to describe 👍 I just used it as I prefer context in my personal code because it reads a bit nicer.

Copy link
Member

@whitlockjc whitlockjc Dec 23, 2016

Choose a reason for hiding this comment

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

I'm using the same setup, VS Code and the Atom One Dark theme. As for context vs. describe, I think it's out of habit honestly. But in this case, consistency is more important.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, updated!

@lumaxis lumaxis force-pushed the definitionsFullyResolved branch from 6713ef2 to fdac8fc Compare December 22, 2016 23:28
@lumaxis lumaxis force-pushed the definitionsFullyResolved branch from fdac8fc to 6d6437c Compare December 23, 2016 01:24
@whitlockjc whitlockjc merged commit 4c63138 into apigee-127:master Dec 23, 2016
@whitlockjc
Copy link
Member

Merged.

@lumaxis lumaxis deleted the definitionsFullyResolved branch January 9, 2017 15:20
@lumaxis lumaxis mentioned this pull request Jan 9, 2017
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.

$ref in a path results in an Unknown Error
3 participants