martian icon indicating copy to clipboard operation
martian copied to clipboard

Support OpenAPI 3 servers specification

Open kiranshila opened this issue 3 years ago • 6 comments

I am pretty new to swagger/openapi in general so please bear with me if this is already solved - I couldn't quite tell if it was the case. I am trying to use this library with Radarr's OpenAPI and am having some problems. Their API is OpenAPI 3, specifically with a servers section as such:

  "servers": [
    {
      "url": "{protocol}://{hostPath}/api/v3",
      "variables": {
        "protocol": {
          "enum": ["https", "http"],
          "default": "https"
        },
        "hostPath": {
          "default": "localhost:7878",
          "description": "Your Radarr Server URL"
        }
      }
    }
  ],

However, trying martian/url-for on one of the endpoints, say :get-movie results in the peculiar URL https://raw.githubusercontent.com{protocol}://{hostPath}/api/v3/movie

Any help would be appreciated as to how to use the servers section of the api with this library. Fantastic work on this, by the way, this library is quite wonderful!

kiranshila avatar Aug 07 '21 17:08 kiranshila

Also, I am bootstrapping with

(def radarr-api
 (martian-http/bootstrap-openapi "https://raw.githubusercontent.com/Radarr/Radarr/develop/src/Radarr.Api.V3/swagger.json"))

kiranshila avatar Aug 07 '21 17:08 kiranshila

Hi,

This is not currently supported in Martian. It probably could be without too much trouble. I'll have to do some reading on what that section means, but probably a first pass to just use the defaults would at least get you able to use it.

Thanks for reporting.

oliyh avatar Aug 15 '21 20:08 oliyh

Hi,

In #129 support was added for an option :server-url in the options when you call bootstrap-openapi. You could change to this as a workaround:

(def radarr-api
 (martian-http/bootstrap-openapi 
    "https://raw.githubusercontent.com/Radarr/Radarr/develop/src/Radarr.Api.V3/swagger.json"
    {:server-url "https://localhost:7878/api/v3"}))

This is available in the latest snapshot 0.1.21-SNAPSHOT

oliyh avatar Jan 25 '22 14:01 oliyh

A question, I have been eyeing this project for loading our OpenAPI 3 spec, is it, in general, supported by martian?

arichiardi avatar Oct 17 '22 20:10 arichiardi

Hi @arichiardi ,

The OpenAPI spec is in general supported by martian, this was added in #90 and #91 with various extra bits added since. This issue in particular is still unaddressed and there are likely other small parts that are not supported but you should find that core functionality is all there.

If you find something missing, issues and PRs are welcome as always.

Cheers

oliyh avatar Oct 18 '22 12:10 oliyh

Please add to Readme this :server-url option. :) It took me a long time to find this here..

damesek avatar Sep 14 '23 12:09 damesek