Fork me on GitHub
#reitit
<
2023-09-13
>
sb19:09:08

Hello, I tried the code from this blog post: https://www.metosin.fi/blog/openapi3, and it worked fine. However, when I attempted to use the Martian library to get the result, I always received an empty array ([]). What did I do wrong?

(try
    (let [m (martian-http/bootstrap-openapi "")]
      (martian/explore m))
    (catch Exception e
      (println "Caught exception: " (.getMessage e))))

ander23:09:03

I believe that you need to add :operationId to the swagger map in the route data. I stumbled over that the other day: https://github.com/oliyh/martian#caveats

sb03:09:54

Thanks, I check it. 👀

sb03:09:10

Ok, I found in the documentation: operationId is an optional unique string used to identify an operation. If provided, these IDs must be unique among all operations described in your API.

sb03:09:24

Thanks the info!

opqdonut10:09:40

good to know!

sb10:09:22

That is worked for me. BUT now I fight with `Execution error (MalformedURLException) at http://java.net.URL/<init> (URL.java:593). no protocol:` …

sb10:09:05

so the prev solution was:

{:get {:openapi {:operationId "spec-plus" :deprecated ...

sb11:09:51

I know what is the problem, but I don’t how to modify the openapi config.. I tried add base-url, server (uri) but nothing happens. The problem is here (response of martian/request-for). The protocol/domain part totally missing. If I add this part.. test manually > works. Any idea?

{:method :get,
   :url "{{MISSING URL PART}}/v1/scramble",
   :query-params ...,
   :as :text,
   :headers {"Accept" "application/json"}}

sb12:09:12

I found the solution in one ticket: {:server-url ..} parameter… different like in original spec.