luckymarmot / API-Flow

Universal data structure and converter for API formats (Swagger, RAML, Paw, Postman…)
MIT License
193 stars 24 forks source link

Generated Postman is invalid against their 2.1.0 spec #149

Closed philsturgeon closed 6 years ago

philsturgeon commented 6 years ago

I'll fix whatever the problem ends up being, but right now I'm getting so many errors that the postman collection generated with API Flow is failing to upload.

[ {
  "level" : "warning",
  "schema" : {
    "loadingURI" : "#",
    "pointer" : "/definitions/certificate/properties/matches"
  },
  "domain" : "syntax",
  "message" : "the following keywords are unknown and will be ignored: [item]",
  "ignored" : [ "item" ]
}, {
  "level" : "error",
  "schema" : {
    "loadingURI" : "#",
    "pointer" : "/properties/item/items"
  },
  "instance" : {
    "pointer" : "/item/0"
  },
  "domain" : "validation",
  "keyword" : "oneOf",
  "message" : "instance failed to match exactly one schema (matched 0 out of 2)",
  "matched" : 0,
  "nrSchemas" : 2,
  "reports" : {
    "/properties/item/items/oneOf/0" : [ {
      "level" : "error",
      "schema" : {
        "loadingURI" : "#",
        "pointer" : "/definitions/item"
      },
      "instance" : {
        "pointer" : "/item/0"
      },
      "domain" : "validation",
      "keyword" : "required",
      "message" : "object has missing required properties ([\"request\"])",
      "required" : [ "request" ],
      "missing" : [ "request" ]
    } ],
    "/properties/item/items/oneOf/1" : [ {
      "level" : "error",
      "schema" : {
        "loadingURI" : "#",
        "pointer" : "/definitions/item-group/properties/item/items"
      },
      "instance" : {
        "pointer" : "/item/0/item/0"
      },
      "domain" : "validation",
      "keyword" : "anyOf",
      "message" : "instance failed to match at least one required schema among 2",
      "nrSchemas" : 2,
      "reports" : {
        "/definitions/item-group/properties/item/items/anyOf/0" : [ {
          "level" : "error",
          "schema" : {
            "loadingURI" : "#",
            "pointer" : "/definitions/request"
          },
          "instance" : {
            "pointer" : "/item/0/item/0/request"
          },
          "domain" : "validation",
          "keyword" : "oneOf",
          "message" : "instance failed to match exactly one schema (matched 0 out of 2)",
          "matched" : 0,
          "nrSchemas" : 2,
          "reports" : {
            "/definitions/request/oneOf/0" : [ {
              "level" : "error",
              "schema" : {
                "loadingURI" : "#",
                "pointer" : "/definitions/request/oneOf/0/properties/header"
              },
              "instance" : {
                "pointer" : "/item/0/item/0/request/header"
              },
              "domain" : "validation",
              "keyword" : "oneOf",
              "message" : "instance failed to match exactly one schema (matched 0 out of 2)",
              "matched" : 0,
              "nrSchemas" : 2,
              "reports" : {
                "/definitions/request/oneOf/0/properties/header/oneOf/0" : [ {
                  "level" : "error",
                  "schema" : {
                    "loadingURI" : "#",
                    "pointer" : "/definitions/header/properties/value"
                  },
                  "instance" : {
                    "pointer" : "/item/0/item/0/request/header/0/value"
                  },
                  "domain" : "validation",
                  "keyword" : "type",
                  "message" : "instance type (null) does not match any allowed primitive type (allowed: [\"string\"])",
                  "found" : "null",
                  "expected" : [ "string" ]
                } ],
                "/definitions/request/oneOf/0/properties/header/oneOf/1" : [ {
                  "level" : "error",
                  "schema" : {
                    "loadingURI" : "#",
                    "pointer" : "/definitions/request/oneOf/0/properties/header/oneOf/1"
                  },
                  "instance" : {
                    "pointer" : "/item/0/item/0/request/header"
                  },
                  "domain" : "validation",
                  "keyword" : "type",
                  "message" : "instance type (array) does not match any allowed primitive type (allowed: [\"string\"])",
                  "found" : "array",
                  "expected" : [ "string" ]
                } ]
              }
            } ],
            "/definitions/request/oneOf/1" : [ {
              "level" : "error",
              "schema" : {
                "loadingURI" : "#",
                "pointer" : "/definitions/request/oneOf/1"
              },
              "instance" : {
                "pointer" : "/item/0/item/0/request"
              },
              "domain" : "validation",
              "keyword" : "type",
              "message" : "instance type (object) does not match any allowed primitive type (allowed: [\"string\"])",
              "found" : "object",
              "expected" : [ "string" ]
            } ]
          }
        } ],
        "/definitions/item-group/properties/item/items/anyOf/1" : [ {
          "level" : "error",
          "schema" : {
            "loadingURI" : "#",
            "pointer" : "/definitions/item-group"
          },
          "instance" : {
            "pointer" : "/item/0/item/0"
          },
          "domain" : "validation",
          "keyword" : "required",
          "message" : "object has missing required properties ([\"item\"])",
          "required" : [ "item" ],
          "missing" : [ "item" ]
        } ]
      }
    } ]
  }
} ]

Tested against Postman Collection v2.1.0 http://schema.getpostman.com/?_ga=2.73374291.1338367236.1512580333-921490803.1512580333

philsturgeon commented 6 years ago

Actually a fun way to test this, take the content from your https://github.com/luckymarmot/API-Flow/tree/master/testing/e2e/internal-postman2/test-case-0/output.json and run it through http://json-schema-validator.herokuapp.com/ with their schema. It has loads of errors and warnings.

I'll fix a few now, including the fact you cannot have null for headers, it's got to be a string!

philsturgeon commented 6 years ago

https://github.com/luckymarmot/API-Flow/pull/154 ensures it's following the v2.0 spec, and that's good enough for me. I'll add in v2.1 support separately.