Skip to content

Returning updated swaggerObject - #141

Closed
pktippa wants to merge 3 commits into
strongloop:masterfrom
pktippa:master
Closed

Returning updated swaggerObject#141
pktippa wants to merge 3 commits into
strongloop:masterfrom
pktippa:master

Conversation

@pktippa

@pktippa pktippa commented Nov 18, 2015

Copy link
Copy Markdown
Contributor

The pull request is fix for #140

@slnode

slnode commented Nov 18, 2015

Copy link
Copy Markdown

Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test."

@pktippa

pktippa commented Nov 24, 2015

Copy link
Copy Markdown
Contributor Author

@bajtos can you please accept this pull request?

@bajtos bajtos self-assigned this Nov 24, 2015
@bajtos

bajtos commented Nov 24, 2015

Copy link
Copy Markdown
Member

Hi @pktippa, thank you for the pull request. To be honest, I don't see how moving a variable declaration (not initialisation!) to a higher scope solves the problem.

Please add a unit-test that fails with the current implementation and passes with your fix in place - that's the best way how to show the correctness of the proposed solution. You can take a look at the unit-test in #22 for inspiration, just note that it has to be updated quite a lot to fit into the current codebase.

@bajtos

bajtos commented Nov 24, 2015

Copy link
Copy Markdown
Member

@slnode ok to test

@bajtos

bajtos commented Nov 24, 2015

Copy link
Copy Markdown
Member

@pktippa I am not sure how familiar you are with GitHub pull request. When reworking this patch, please keep using the same git branch & github pull request, do not open a new one. You can simply keep adding more commits here, as we can clean the history at the end, just before merging the code.

@pktippa

pktippa commented Nov 25, 2015

Copy link
Copy Markdown
Contributor Author

@bajtos I am not that familiar with writing test cases, please help me.

@bajtos

bajtos commented Nov 27, 2015

Copy link
Copy Markdown
Member

@pktippa Start with reading the unit-test in #22, it's a good one. Rework it to work in the current codebase. Then think about any edge cases that would not be covered by that test and write additional tests for these edge cases.

When adding a new test, it's important to see it fail for the reason you expected. This has multiple purposes: it ensures the test actually tests something (as opposed to tests that always passes because they are based on incorrect assumptions) and also that the failure message is helpful enough to identify the source of the problem.

@pktippa

pktippa commented Dec 2, 2015

Copy link
Copy Markdown
Contributor Author

@bajtos The issue is with express itself. I have created a sample express app using express generator and added routes to create dynamic routes and respond with global and local scope varaibles, added test cases written in supertest and published the project in github named express-route-bug, please fork/check out the project run "npm test" to validate it.

If you find its a valid bug, Please report the same to express issues.

I think since the bug is with express itself, Let me know if I still have to write test cases for this issue #140 .

@bajtos

bajtos commented Dec 3, 2015

Copy link
Copy Markdown
Member

@pktippa I am afraid I don't see how is your test case in express-route-bug related to the work made here?

Let me rephrase the test scenario from #22.

  1. Create a loopback app
  2. Setup explorer on this app
  3. GET /explorer/swagger/json to ensure any lazy initialisation is executed
  4. Add a new model
  5. GET /explorer/swagger/json and check that the new model is included

@pktippa

pktippa commented Dec 7, 2015

Copy link
Copy Markdown
Contributor Author

@bajtos I have completed writing test cases for new model creation and existence of new model in the swagger.json

@pktippa

pktippa commented Dec 7, 2015

Copy link
Copy Markdown
Contributor Author

@bajtos for your query.

To be honest, I don't see how moving a variable declaration (not initialisation!) to a higher scope solves the problem.

Please go through the conversation below and explanation given by @dougwilson
expressjs/express#2822

@pktippa

pktippa commented Dec 9, 2015

Copy link
Copy Markdown
Contributor Author

Hi @bajtos can you please look into the test cases and accept this PR.

Comment thread test/explorer.test.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You should not need to call explorer(app) again, lines 274-275 should be removed as well.

When you call explorer(app) again, it will add a duplicate set of routes to the application. Each express route incurs a small performance penalty, therefore adding unnecessary duplicate routes can cause performance degradation.

Also the code adding new models should not need to be aware of the fact that the app is using explorer. Your current solution creates a coupling between unrelated parts of the system which is a bad practice.

So, please remove L273-L275, I am suggesting to move L269-L271 back to the test method and get rid of createNewModel entirely.

@pktippa

pktippa commented Dec 10, 2015

Copy link
Copy Markdown
Contributor Author

Hi @bajtos

I have modified the code and tested, please check it once.

Please let me know revert commits and push a single commit for this pull request and let me know the steps as well, since I am new to git and github.

@bajtos

bajtos commented Dec 10, 2015

Copy link
Copy Markdown
Member

Hi @pktippa, thank you for the update, the new code looks much better. Unfortunately you have messed up whitespace in your last commit, see diff and diff ignoring whitespace changes. Could you please restore the original whitespace? It will make it much easier for me to comment on your changes.

Please let me know revert commits and push a single commit for this pull request and let me know the steps as well, since I am new to git and github.

You need to run git rebase -i master, then choose "squash" for all commits except the first (top) one. Once rebased, you need git push -f.

Don't worry about it now, it's best to clean up the history only at the very end, once the patch is good to be landed.

	- explorer.test.js and index.js got modified as per the comments
	given by @bajtos
@pktippa

pktippa commented Dec 10, 2015

Copy link
Copy Markdown
Contributor Author

Hi @bajtos

Unfortunately you have messed up whitespace in your last commit,

That happened because of the copying the code and switching editor from notepad++ to eclipse.

Could you please restore the original whitespace? It will make it much easier for me to comment on your changes.

I reverted the previous commit and restored original white space, please have a look at it once.

Don't worry about it now, it's best to clean up the history only at the very end, once the patch is good to be landed.

Ok.

@bajtos

bajtos commented Dec 17, 2015

Copy link
Copy Markdown
Member

Hi @pktippa, thank you for fixing the whitespace, the diff looks much better now!

I am afraid I am very tight on time right now and don't have enough bandwidth to finish the review. I ask for your patience, I'll get back to this as soon as my schedule permits.

@pktippa

pktippa commented Dec 17, 2015

Copy link
Copy Markdown
Contributor Author

Hi @bajtos,

I am afraid I am very tight on time right now and don't have enough bandwidth to finish the review. I ask for your patience, I'll get back to this as soon as my schedule permits.

We are running a private npm using sinopia and I published this fix in our private repo. Looking for this fix to go public :)

@bajtos

bajtos commented Jan 5, 2016

Copy link
Copy Markdown
Member

@pktippa to speed things up, I made few remaining changes myself and landed the patch via 9e8a19f. Thank you for the contribution!

@pktippa

pktippa commented Jan 6, 2016

Copy link
Copy Markdown
Contributor Author

@bajtos thanks for landing the patch. On which node module version this patch will be available.?

@bajtos

bajtos commented Feb 2, 2016

Copy link
Copy Markdown
Member

@pktippa sorry for the delay. I have just released loopback-component-explorer@2.3.0 that includes your patch too. Enjoy!

@pktippa

pktippa commented Feb 2, 2016

Copy link
Copy Markdown
Contributor Author

@bajtos Thanks 👍

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.

4 participants