https://github.com/damesek/swagger-http-kit-compojure-api
Compojure API test and Swagger API integration example (works with uberjar)
https://github.com/damesek/swagger-http-kit-compojure-api
Last synced: about 1 year ago
JSON representation
Compojure API test and Swagger API integration example (works with uberjar)
- Host: GitHub
- URL: https://github.com/damesek/swagger-http-kit-compojure-api
- Owner: damesek
- License: gpl-3.0
- Created: 2017-04-18T20:02:03.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-18T20:25:53.000Z (about 9 years ago)
- Last Synced: 2023-09-12T10:42:15.878Z (almost 3 years ago)
- Language: Clojure
- Size: 22.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Swagger and Compojure API with Clojure Http-kit
Compojure API test and Swagger API integration example (work with uberjar compile)
I found just Arttuka http-kit swagger tutorial. `https://github.com/arttuka/swagger-httpkit-test`. End of this tutorial you can read: "Doesn't currently work because of a suspected problem in compojure-api and AOT compiling."
.. that wasn't good news for me .. and not so happy! I try to find a solution for this. That is my quick demonstration how works the swagger/ compojure-api with http-kit. Plus you can compile with uberjar.
First way to create REST-API:
```
(GET "/apitest" [challenge :as request]
(let [challenge (or (get-in request [:params :challenge])
(get-in request [:body :challenge])
"John Doe")]
{:status 200
:body [challenge]}))
```
Second way with Swagger:
```
(POST "/bot" [challenge]
:return {:challenge String}
:query-params [challenge]
(ok {:challenge challenge}))
; swagger api editor: localhost:8080/api-editor
```
How to run?
`lein run`
After this check in the browser:
`localhost:8080`
How to compile with uberjar in this case?
`lein with-profile uber uberjar`
How to start server?
`java -jar target/swagger-httpkit-test-uberjar.jar`
Of course, you can improve this. That is just a quick tutorial.
Have a nice day,
Szabolcs