oliyh / martian

The HTTP abstraction library for Clojure/script, supporting OpenAPI, Swagger, Schema, re-frame and more
MIT License
529 stars 44 forks source link

Unable to use martian over spotinst API #169

Open fhalde opened 1 year ago

fhalde commented 1 year ago

I've been trying to use the Martian library for the following openapi spec https://docs.spot.io/api/

The regular bootstrap-openapi requires a HTTP endpoint to get the schema however there is no endpoint as such for spotinst. so i had to handroll my own bootstrap that prepares the definition from the map

Anyway, once I had the martian object bootstrapped I had the following issue

Taking the following path from the openapi

  "paths": {
    "/aws/ec2/group": {
      "summary": "Elastigroups for AWS",
      "post": {
        "summary": "Create Elastigroup",

It has 1 Query parameter accountId and a requestBody of type #/components/schemas/elastigroupCreate

However when I do a explore for elastigroup-aws-create I get the following

{:summary "Create Elastigroup", :parameters {:account-id java.lang.String, :body Any}, :returns {200 Any, 400 nil}}

Why is the body of type Any ? This results in any map being accepted and eventually the server returns with a validation error

fhalde commented 1 year ago

Please note, there is a bug in the spotinst openapi line number 67726. it needs to be an integer instead of string

this was another major problem that took me so long to debug. bootstrap-openapi returned fine however upon using explore, I used to get a schema validation error because the default value didn't conform to the spec

oliyh commented 1 year ago

Hello,

I suspect it is the "allOf" schema combinator that Martian doesn't understand, unless you have a counterexample?

"requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/elastigroupCreate"
                  }
                ]
              }
            }
          }
        },
fhalde commented 1 year ago

no I don't and you may be right in that case :( any idea of the work involved to support it?

oliyh commented 1 year ago

Might not be too bad, but I'm a bit short on time at the moment. I'll try to find time to look soon.