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

yada/swaggered seems to think this regex is a part of the resource path #41

Closed
imrekoszo opened this issue Nov 22, 2015 · 1 comment · Fixed by #81
Closed

yada/swaggered seems to think this regex is a part of the resource path #41

imrekoszo opened this issue Nov 22, 2015 · 1 comment · Fixed by #81

Comments

@imrekoszo
Copy link
Contributor

I have a resource where an email address is part of the path like "/foo/by-email/aaaa@example.com"

A bidi route accepting this with :email as a route param would look like:

[["/foo/" [#".+\@.+\..+" :email]] :foo]

Note the regex format for the :email param which is required by bidi to parse the email as a route param. This is explained in juxt/bidi#98 (comment)

When I created a yada/swaggered api on top of such a routing I got an error saying Pattern does not implement the encode method of yada.swagger/SwaggerPath which makes me think yada/swaggered thinks the regex in the above example is a separate path element from :email. For now I fixed it in my project with:

(extend-protocol yada.swagger/SwaggerPath
  java.util.regex.Pattern (encode [_] nil))

But I doubt this is the right thing to do in the long term.

@malcolmsparks
Copy link
Contributor

Thanks, this is definitely a valid issue - let's keep it open for now and I'll work on a proper fix.

griff added a commit to griff/yada that referenced this issue Apr 6, 2016
When the bidi route had path parameters but those parameters where not
defined in the resource the swagger output would have the path
parameter shown in the url but would be missing the definition for the
parameter. Similarly when the bidi route had qualifiers for the path
parameters you couldn't even generate the swagger output. This commit
fixes these issues so the swagger ouput now reflects what yada actually
does when handling a request.

When no path parameters are defined for a resource yada will simply
forward the path parameters from bidi directly with no check or
coercion. Meaning that bidi does all the type checking and coercion and
this commit will include the bidi path parameters with types in the
swagger output.

But when a resource does have path parameters defined these must cover
all path parameters and so overwrites whatever bidi has specified for
the parameters.

Fixes juxt#41
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 a pull request may close this issue.

2 participants