swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

How to valid input data type on swagger-ui

Open zon999 opened this issue 11 years ago • 5 comments

Hi all, My model schema: { "wareHouseID": 0, "parentID": 0, "name": "string", "fullname": "string", "company": "string", "address": "string" }

Now i want to catch error if input wareHouseID and parentID are "String".
Tell me what should i do? Thanks

zon999 avatar Oct 09 '15 09:10 zon999

That's out of scope for swagger-core, the project does Swagger specification generation, not validation.

webron avatar Oct 09 '15 21:10 webron

Thanks @webron.

zon999 avatar Oct 10 '15 01:10 zon999

{
  "id": String,
  "category": {
    "id": 0,
    "name": "string"
  },
  "name": "doggie",
  "photoUrls": [
    "string"
  ],
  "tags": [
    {
      "id": 0,
      "name": "string"
    }
  ],
  "status": "available"
}

When input id is String
pet store swagger result: 
{
  "code": 400,
  "type": "unknown",
  "message": "bad input"
}

How can i catch same this.

zon999 avatar Oct 10 '15 01:10 zon999

That's just regular code, again, not specific to swagger-core. You can check the source code for the pet store here - https://github.com/swagger-api/swagger-samples/tree/master/java/java-jersey-jaxrs.

webron avatar Oct 12 '15 22:10 webron

Hi, the JSON above is actually not valid--"id":String is missing quotes. Please reopen an issue in swagger-ui if you think there's a problem still.

fehguy avatar Oct 19 '15 20:10 fehguy