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

Emitting warnings for inconsistent API doc elements #1189

Merged
merged 4 commits into from
Mar 21, 2022
Merged

Emitting warnings for inconsistent API doc elements #1189

merged 4 commits into from
Mar 21, 2022

Conversation

Lucas-C
Copy link
Contributor

@Lucas-C Lucas-C commented Mar 17, 2022

The goal of this PR is to generate warnings for inconsistent API doc comments.

For example, the following comment:

/**
* @api {GET} /resource/:resId/sub/:subId getSubResource
* @apiParam {String} subId
*/

...would trigger this warning:

warn: URL contains a parameter ':resId' that is not documented as @apiParam in @api 'getSubResource' in file: 'api.js'

A warning would also be emitted in case of parameter name mismatch:

/**
* @api {GET} /resource/:resId getSubResource
* @apiParam {String} id
*/

Copy link
Collaborator

@NicolasCARPi NicolasCARPi left a comment

Choose a reason for hiding this comment

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

Hello, thank you for wanting to contribute to apidoc. Your proposition looks great. Could you please try and add a test case for your new code?

@Lucas-C
Copy link
Contributor Author

Lucas-C commented Mar 18, 2022

Sure, I have just added a unit test

@Lucas-C Lucas-C changed the title Emitting warnings for incoherent API doc elements Emitting warnings for inconsistent API doc elements Mar 18, 2022
@Lucas-C
Copy link
Contributor Author

Lucas-C commented Mar 19, 2022

The GitHub Actions pipeline is ✔️: https://github.com/voyages-sncf-technologies/apidoc/actions/runs/2008326289

@NicolasCARPi
Copy link
Collaborator

We could even push further and add a warning if there is an api param that doesn't correspond to anything (so the other way around). Code that would emit a warning:

/**
 * @api {get} /user/:id
 * @apiParam {Number} id user id
 * @apiParam {String} oops some leftover
 */

Would you be willing to add this to your PR?

@Lucas-C
Copy link
Contributor Author

Lucas-C commented Mar 20, 2022

OK, I also added that check

Pipeline is ✔️: https://github.com/voyages-sncf-technologies/apidoc/actions/runs/2012844549

Copy link
Collaborator

@NicolasCARPi NicolasCARPi left a comment

Choose a reason for hiding this comment

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

Thanks, great work!

@NicolasCARPi NicolasCARPi merged commit d7af64f into apidoc:dev Mar 21, 2022
@Lucas-C
Copy link
Contributor Author

Lucas-C commented Mar 21, 2022

Thank you for maintaining this lib, and for accepting my contribution 😊

@Lucas-C Lucas-C deleted the warnings-for-url-params-missing-doc branch October 26, 2022 12:43
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