kogosoftwarellc / open-api

A Monorepo of various packages to power OpenAPI in node
MIT License
891 stars 234 forks source link

200 is invalid #52

Closed notxt closed 8 years ago

notxt commented 8 years ago

Getting:

September 16 22:59:13: express-openapi:  validation errors [
  {
    "property": "instance.paths./provider.post.parameters[2]",
    "message": "is not exactly one from <#/definitions/parameter>,<#/definitions/jsonReference>",
    "schema": {
      "oneOf": [
        {
          "$ref": "#/definitions/parameter"
        },
        {
          "$ref": "#/definitions/jsonReference"
        }
      ]
    },
    "instance": {
      "name": "columns",
      "in": "body",
      "description": "Columns to include in response",
      "type": "array",
      "schema": {
        "$ref": "#/definitions/columnList"
      }
    },
    "name": "oneOf",
    "argument": [
      "<#/definitions/parameter>",
      "<#/definitions/jsonReference>"
    ],
    "stack": "instance.paths./provider.post.parameters[2] is not exactly one from <#/definitions/parameter>,<#/definitions/jsonReference>"
  },
  {
    "property": "instance.paths./provider.post.responses[200]",
    "message": "is not exactly one from <#/definitions/response>,<#/definitions/jsonReference>",
    "schema": {
      "oneOf": [
        {
          "$ref": "#/definitions/response"
        },
        {
          "$ref": "#/definitions/jsonReference"
        }
      ]
    },
    "instance": {},
    "name": "oneOf",
    "argument": [
      "<#/definitions/response>",
      "<#/definitions/jsonReference>"
    ],
    "stack": "instance.paths./provider.post.responses[200] is not exactly one from <#/definitions/response>,<#/definitions/jsonReference>"
  }
]

when I try to do the example in the readme

I'm a bit new to openapi but it seems like it's not recognizing 200 as a valid responses key, which I believe it should be

... michael

jsdevel commented 8 years ago

Can you change type to $ref for the items definition? It should look like this:

items: {
  $ref: '#/definitions/World'
}
jsdevel commented 8 years ago

Updated the README. Let me know if this is still an issue for you @notxt. Thanks for reporting it!

notxt commented 8 years ago

works! there was one other little error that I put in a pr for

https://github.com/kogosoftwarellc/express-openapi/pull/53

jsdevel commented 8 years ago

Thanks a ton @notxt ! I hope you enjoy the framework.

notxt commented 8 years ago

oh I'm already loving it, I was a big fan of swagger via hapi-swagger which I used at my old job. Just got a new one and they use express. It's taken me a minute find good equivalent but I'm liking your philosophy of Stays as close to express as possible.

How long has the project been around?

jsdevel commented 8 years ago

It's been around for about 9 months. I developed it while at my last contract. We started off using swaggerize-express, but found that one to be too buggy. I wanted a framework that leveraged jsonschema which the main reason I wrote this.