Implement security fields from openapi to malli route data.#14
Implement security fields from openapi to malli route data.#14JohanCodinha wants to merge 4 commits into
Conversation
…e-vector] pairs.
|
thanks! will have a look asap! |
|
Implement security as a malli route data, this can then be read by interceptor / midleware. Given a doc like: Produce routes like: |
|
Need to add a test, only tested at the repl with no security info, with 1 and with many. |
| ; https://opensource.org/licenses/MIT. | ||
|
|
||
| {:deps {io.swagger.parser.v3/swagger-parser {:mvn/version "2.1.25"}} | ||
| :paths ["resources" "src"] |
There was a problem hiding this comment.
can we remove this and put the test dir? in something like a specs dir maybe. we can just use (slurp "specs/security-users.yml"). I'd rather not have things that aren't part of the final artifact in resources.
There was a problem hiding this comment.
Yes, it makes sense I just added this to have a repl going.
| (->> security-reqs | ||
| (mapcat seq) | ||
| (map (juxt key val)) | ||
| (into []))) |
There was a problem hiding this comment.
this into can be dropped for a mapv before this?
There was a problem hiding this comment.
thinking more, is this conversion even needed or does is just work in reitit as its all Maps and Lists anyways?
There was a problem hiding this comment.
This is just creating route data. It won't work in reitit until you add middleware that uses that data.
Although it's opinionated, I chose to represent it as a vector of vectors because it convey the logical OR of having multiple security schemes.
This could have been a map but I think of map a as AND.
And yes, this can also be done with a mapv, feel free to change it.
There was a problem hiding this comment.
Makes sense. Let's add some docs about it on the README.
| "listUsersSingle" (constantly :ok) | ||
| "listUsersNoScope" (constantly :ok) | ||
| "listUsersNoSecurity" (constantly :ok)} | ||
| api-spec (slurp (io/resource "security-users.yml")) |
There was a problem hiding this comment.
lets use a slurp without the resource like mentioned before
|
Rest looks pretty good! thanks! |
|
@JohanCodinha can I get some reitit middleware/interceptor examples for the readme thst uses this? I'm happy to merge this after that. 😄 |
No description provided.