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

WIP: swagger/ui support #206

Closed
wants to merge 1 commit into from
Closed

WIP: swagger/ui support #206

wants to merge 1 commit into from

Conversation

avelino
Copy link
Member

@avelino avelino commented Dec 23, 2023

fixed: #205

Summary by CodeRabbit

  • New Features

    • Integrated Swagger for enhanced API documentation.
    • Added Swagger UI for interactive API exploration.
  • Documentation

    • Updated API documentation accessible via Swagger UI.
  • Refactor

    • Improved HTTP security settings.
    • Streamlined server startup configuration.
  • Dependencies

    • Added new dependencies for API documentation features.

Signed-off-by: Avelino <31996+avelino@users.noreply.github.com>
Copy link
Contributor

coderabbitai bot commented Dec 23, 2023

Walkthrough

The project has integrated Swagger using metosin/reitit-swagger and metosin/reitit-swagger-ui for enhanced API documentation and user interface. Additionally, security has been improved by setting content security policies, and there has been some cleanup in the server startup code.

Changes

File Path Change Summary
deps.edn Added metosin/reitit-swagger and metosin/reitit-swagger-ui, updated clj-http.
src/com/.../server.clj Added secure headers for content security policy; removed redundant server startup lines.
src/com/.../specs/moclojer.clj Imported reitit.swagger and reitit.swagger-ui; added :swagger {} and Swagger UI routes.

🐇💻
To code by day, to hop by night,
Our docs now clear, our APIs bright.
With Swagger's charm, we leap ahead,
In secure fields of web, we tread. 🌟🌐

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on X ?


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
  • You can tag CodeRabbit on specific lines of code or entire files in the PR by tagging @coderabbitai in a comment. Examples:
  • You can tag @coderabbitai in a PR comment and ask questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions. Examples:
    • @coderabbitai render interesting statistics about this repository as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai generate unit tests for the src/utils.ts file.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@avelino
Copy link
Member Author

avelino commented Dec 23, 2023

error 500 in GET /swagger.json"

INFO [io.pedestal.http] - {:msg "GET /swagger.json", :line 80}
INFO [io.pedestal.http.cors] - {:msg "cors request processing", :origin nil, :allowed true, :line 84}
SEVERE [io.pedestal.http.impl.servlet-interceptor] - {:msg "error-ring-response triggered", :context {:io.pedestal.in
terceptor.chain/stack (#Interceptor{:name :io.pedestal.http.impl.servlet-interceptor/stylobate} #Interceptor{:name :i
o.pedestal.http.impl.servlet-interceptor/terminator-injector}), :request {:protocol "HTTP/1.1", :async-supported? tru
e, :remote-addr "127.0.0.1", :servlet-response #object[org.eclipse.jetty.server.Response 0x6dbc2a5a "HTTP/1.1 200 \nD
ate: Sat, 23 Dec 2023 11:23:00 GMT\r\n\r\n"], :servlet #object[io.pedestal.http.servlet.FnServlet 0x74bca66d "io.pede
stal.http.servlet.FnServlet@74bca66d"], :headers {"sec-fetch-site" "same-origin", "host" "127.0.0.1:8000", "user-agen
t" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:122.0) Gecko/20100101 Firefox/122.0", "connection" "keep-alive",
 "accept" "*/*", "accept-language" "pt-BR,en-US;q=0.5", "sec-fetch-dest" "empty", "accept-encoding" "gzip, deflate, b
r", "sec-fetch-mode" "cors", "cache-control" "max-age=0"}, :server-port 8000, :servlet-request #object[org.eclipse.je
tty.server.Request 0x28beb989 "Request(GET //127.0.0.1:8000/swagger.json)@28beb989"], :path-info "/swagger.json", :ur
l-for #object[clojure.lang.Delay 0x6db6f0a5 {:status :pending, :val nil}], :uri "/swagger.json", :server-name "127.0.
0.1", :query-string nil, :path-params {}, :body #object[org.eclipse.jetty.server.HttpInputOverHTTP 0x195cd082 "HttpIn
putOverHTTP@195cd082[c=0,q=0,[0]=null,s=STREAM]"], :scheme :http, :request-method :get, :context-path ""}, :bindings
{#'io.pedestal.http.route/*url-for* #object[clojure.lang.Delay 0x6db6f0a5 {:status :pending, :val nil}]}, :enter-asyn
c [#object[io.pedestal.http.impl.servlet_interceptor$start_servlet_async 0x7ec6a849 "io.pedestal.http.impl.servlet_in
terceptor$start_servlet_async@7ec6a849"]], :io.pedestal.interceptor.chain/terminators (#object[io.pedestal.http.impl.
servlet_interceptor$terminator_inject$fn__25397 0x15bec709 "io.pedestal.http.impl.servlet_interceptor$terminator_inje
ct$fn__25397@15bec709"]), :servlet-response #object[org.eclipse.jetty.server.Response 0x6dbc2a5a "HTTP/1.1 200 \nDate
: Sat, 23 Dec 2023 11:23:00 GMT\r\n\r\n"], :route {:path "/swagger.json", :method :get, :path-re #"/\Qswagger.json\E"
, :path-parts ["swagger.json"], :interceptors [#Interceptor{}], :route-name :swagger-json, :path-params {}, :io.pedes
tal.http.route.prefix-tree/satisfies-constraints? #object[clojure.core$constantly$fn__5740 0x489146c6 "clojure.core$c
onstantly$fn__5740@489146c6"]}, :servlet #object[io.pedestal.http.servlet.FnServlet 0x74bca66d "io.pedestal.http.serv
let.FnServlet@74bca66d"], :servlet-request #object[org.eclipse.jetty.server.Request 0x28beb989 "Request(GET //127.0.0
.1:8000/swagger.json)@28beb989"], :url-for #object[clojure.lang.Delay 0x6db6f0a5 {:status :pending, :val nil}], :io.p
edestal.interceptor.chain/execution-id 2, :servlet-config #object[org.eclipse.jetty.servlet.ServletHolder$Config 0x53
c016b6 "org.eclipse.jetty.servlet.ServletHolder$Config@53c016b6"], :async? #object[io.pedestal.http.impl.servlet_inte
rceptor$servlet_async_QMARK_ 0x188f7867 "io.pedestal.http.impl.servlet_interceptor$servlet_async_QMARK_@188f7867"]},
:line 253}

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 5cbfa14 and 345d923.
Files selected for processing (3)
  • deps.edn (1 hunks)
  • src/com/moclojer/server.clj (2 hunks)
  • src/com/moclojer/specs/moclojer.clj (3 hunks)
Files skipped from review due to trivial changes (1)
  • src/com/moclojer/server.clj
Additional comments: 6
src/com/moclojer/specs/moclojer.clj (4)
  • 5-7: Added imports for Swagger support.

  • 43-43: The :swagger {} map is empty. Ensure that it is intentionally left empty and not missing configuration details.

  • 44-44: Ensure that the :body key in the generic-handler function correctly builds the response body as intended.

  • 78-88: Swagger and Swagger UI routes have been added. Verify that these routes are accessible and properly configured according to the project's standards.

deps.edn (2)
  • 16-18: Dependencies for Swagger support have been added. Ensure that the versions are compatible with the project and that they do not introduce any conflicts with existing dependencies.

  • 16-16: The clj-http dependency has been updated. Confirm that this version is compatible with the project and that all existing functionality that relies on clj-http continues to work as expected.

@matheusfrancisco
Copy link
Member

@avelino I was looking to this pr but couldnt figure out yet. Not sure but it maybe we have to change more to use it with pedestal https://github.com/metosin/reitit/blob/master/examples/pedestal-swagger/src/example/server.clj

@matheusfrancisco
Copy link
Member

there was too many conflict to fix it, so I'm open a new branch for this

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.

automatically generate documentation - openAPI (swagger)
2 participants