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

Update rxVersion with optional space #2212

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Conversation

smitt04
Copy link

@smitt04 smitt04 commented Feb 4, 2020

Fix for #2125

Add .Context to location template context

Signed-off-by: Kevin Smithson <smitt04@gmail.com>
@fredbi fredbi added the generate spec Related to spec generation from code label Feb 8, 2020
Copy link
Contributor

@fredbi fredbi left a comment

Choose a reason for hiding this comment

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

No tests

@@ -81,7 +81,7 @@ var (
rxResponses = regexp.MustCompile(`[Rr]esponses\p{Zs}*:`)
rxParameters = regexp.MustCompile(`[Pp]arameters\p{Zs}*:`)
rxSchemes = regexp.MustCompile(`[Ss]chemes\p{Zs}*:\p{Zs}*((?:(?:https?|HTTPS?|wss?|WSS?)[\p{Zs},]*)+)$`)
rxVersion = regexp.MustCompile(`[Vv]ersion\p{Zs}*:\p{Zs}*(.+)$`)
rxVersion = regexp.MustCompile(`^\s*[Vv]ersion\p{Zs}*:\p{Zs}*(.+)$`)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is an ad'hoc fix. This might fix your specific use-case but it breaks any attempt to consistently analyze tags.

Why version should be treated in a special way, and other tags wouldn't have the ability to get leading blank space?

Wouldn't the solution to your issue rather lie around how to determine the boundaries of the swagger:meta?

Copy link
Author

Choose a reason for hiding this comment

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

I think the other meta tags could start with an optional space also. Currently, it just checks if any of the words are anywhere in the comment. But they should be the first think on a line instead of in a sentence or part of another word. I do realize this isn't a perfect solution as there may be some cases where you don't want to match one of these words on a line by itself. In my use case, it would be hard to determine the boundaries of swagger:meta as I have markdown docs right above the start of the tags. Unless we had a start and end symbol to say these lines in between should be part of the swagger:meta yaml and nothing else. Let me know what you would like to do. I can update the other regexes to include optional spaces if you think that would suffice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
generate spec Related to spec generation from code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants