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: Comments to skip multiple endpoints #469

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Javakky-pxv
Copy link
Collaborator

@Javakky-pxv Javakky-pxv commented Jul 13, 2022

In my product, web pages and API endpoints live together, so I need to include so many "### NoDocs ###".
To avoid this, I created a feature that allows multiple endpoints to be ignored by using "### NoDocsStart ###" and "### NoDocsEnd ###".

e.g.

### NoDocsStart ###
GET      /api/hidden/a                 controllers.hiddenEndPointA()
GET      /api/hidden/b                 controllers.hiddenEndPointB()
### NoDocsEnd ###
###
#  summary: I'm not hiding!
###
GET      /api/hidden/c                 controllers.hiddenEndPointC()

@Javakky-pxv Javakky-pxv requested a review from kailuowang July 13, 2022 06:29
@Javakky-pxv
Copy link
Collaborator Author

Javakky-pxv commented Jul 13, 2022

Excerpt from README.

Multiple lines can be skipped.

※NoDocsEnd must always be listed directly before one line as a comment on the endpoint not to be skipped, or on the last line of the routes fill.

### NoDocsStart ###
GET      /api/hidden/a                 controllers.hiddenEndPointA()
GET      /api/hidden/b                 controllers.hiddenEndPointB()
### NoDocsEnd ###
GET      /api/hidden/c                 controllers.hiddenEndPointC()

@Javakky-pxv Javakky-pxv force-pushed the javakky/multiple-no-docs branch from a31856a to 4a78a15 Compare July 13, 2022 07:54
@Javakky-pxv

This comment was marked as resolved.

@kailuowang
Copy link
Collaborator

I apologize. I thought I left a comment but obviously, I didn't actually click the comment button.
This feature will be pretty useful for sure. But I have concerns over how it's designed.
A start marker and an end marker mean that you have to track the state (like what's in between); this is extra complexity in both play-swagger code base and end-user usages. To best demonstrate this, let me use an alternative: instead of a start and end marker, we could provide an ignore whole file marker, something like

### SkipFileForDocs ###

User can put this comment at the top of the file and we can ignore the whole file. This way user won't have to worry about tracking start and end marker (e.g. accidentally delete or add an extra marker that breaks the pair). Code in play-swagger might be simpler as well.
That being said, I don't actually know if it's easier for you to skip the whole file. If that's not the case maybe we have to go this route.

@Javakky-pxv

This comment was marked as resolved.

@Javakky-pxv Javakky-pxv changed the title Feat: Comments to skip multiple endpoints feat: Comments to skip multiple endpoints Jul 27, 2022
@Javakky-pxv
Copy link
Collaborator Author

@kailuowang
I don't want to be forced to split my routes file! On the other hand, I feel that it would be possible to semantically separate APIs that need to be documented from those that do not.
I'll try @kailuowang's idea first and see how it works before I submit this pull request.

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.

2 participants