knuckleswtf / scribe-js

Generate API documentation for humans from your Node.js codebase.
https://scribe.knuckles.wtf/nodejs/
52 stars 8 forks source link

Description for @urlParam is ignored #6

Closed jipis closed 3 years ago

jipis commented 3 years ago

I have the following

/**
* Here be my title
*
* And this is a description
*
* @urlParam {string} theParam required This should be the description. Example: its-a-string
* @urlParam {int} anotherParam This is another description
*/
server.get('/:theParam/:anotherParam', (req, res, next) => {
...

It seems that the @urlParam parser is ... exiting early? I can't provide a screenshot for unimportant reasons. But, what I get as output in the html page here is the "URL Parameters" header followed by theParam string anotherParam string

It is completely ignoring everything other than the @urlParam and the variable name tokens on those lines. The example text isn't used in the example request. The description is completely missing. required vs not having it there makes no difference. And the type is even ignored (as the int is showing in the doc as string).

shalvah commented 3 years ago

Okay, but you need to provide environment information. Framework, versions, etc.

Also, have you tried updating to the latest version first?

jipis commented 3 years ago

Oops, sorry.

I was looking for a template to follow to indicate all info you want/need for bug reports, but I didn't see one. Gave as much as I thought of offhand.

I'm using restify 8.5.1 with scribe-restify 1.2.0 on node 15.6.0.

shalvah commented 3 years ago

Yeah, that was an oversight. 😅 Added a template now.

Try upgrading to the latest version of the package first (1.6.0). Note that in the latest version, you don't need to add the require(...) statement to your code anymore.

jipis commented 3 years ago

ok, I'm up to 1.8.1 now.

/**
 * Decode a tinyUrl
 *
 * Take a tiny URL (previously generated), look it up in the database,
 * and redicrect the browser to it.
 *
 * @urlParam {string} tinyUrlId required The id of the tinyUrl to redirect to. Example: 14e2b706-d4fc-11eb-9b30-0e285caff4d5
 * @urlParam {int} foo This is made up for example purposes. Example: 41380
 */
server.get('/:tinyUrlId/:foo', (req, res, next) => {

Generates image

Note how really everything other than the name of the param (to include the required/not-required, description, type, and example) is ignored.

shalvah commented 3 years ago

On it.

shalvah commented 3 years ago

Can you try now? Should be fixed now (v1.8.2).

jipis commented 3 years ago

Erm, actually, worse. Exact same code as listed above. Upgraded to 1.8.2. And got this: image

Note that "Endpoints" has become "undefined". And the entire docblock is apparently being ignored now.

shalvah commented 3 years ago

Ah, fuck. I think I know what's the problem.

shalvah commented 3 years ago

Okay, fixed for real this time.😅 1.8.3

jipis commented 3 years ago

Ooh, almost! The documentation itself seems to be right now. Just the example is off now. Same code as above now generates this. image

Tried to take a look myself, but it looks like the code to generate 1.8.3 didn't get pushed to github.

shalvah commented 3 years ago

Fixed now 👍

BTW, the TS code is in the src/ folder. Generated is in dist/. I'll add a contributing guide for v2, but in the meantime, you can actually just edit the generated files if you can't find any other way.

jipis commented 3 years ago

We have a winner!!

Thanks so much for your help! Good to go!

For reference, same code as before is now awesomely correctly generating

image

shalvah commented 3 years ago

Awesome.👍

Watch out for v2, coming with more customizability and smarter inference.