swagger-api / validator-badge

Validate your Swagger JSON/YAML today!
http://swagger.io
Apache License 2.0
210 stars 85 forks source link

Validator debug returns 500 #25

Closed mattfrear closed 9 years ago

mattfrear commented 9 years ago

Hi

I'm getting a nice red ERROR badge on my site: http://co-delv-dev.trafficmanager.net/swagger/ui/index

When I click the badge to debug the swagger to see what's wrong, I get redirected to http://online.swagger.io/validator/debug?url=http://co-delv-dev.trafficmanager.net:80/swagger/docs/v1 Which renders: HTTP ERROR 500

Problem accessing /validator/debug. Reason:

Internal Server Error
webron commented 9 years ago

In this case, it's because of the examples field in the responses. This is not a problem with your spec, just clarifying what needs to be fixed in the validator.

mkrouwer commented 9 years ago

I am getting the same 500 validation error, and when I checked out my site in: http://online.swagger.io/validator/debug?url= "my url" I still just got "Internal server error", I don't see anything wrong with my spec and swagger works well with my api it's just the validator that's complaining, is this a bug?

webron commented 9 years ago

@mkrouwer - there are several bugs around it. Even if the definition is fine, the validator may throw errors. If you can provide us with your definition, it would help us cover more related bugs.

mkrouwer commented 9 years ago

definitions: { Company.Model.Domain.Model: { type: "object", properties: { ModelType: { type: "string" }, Id: { type: "string" }, Name: { type: "string" }, Description: { type: "string" }, CreatedById: { type: "string" }, Created: { format: "date-time", type: "string" }, ModifiedById: { type: "string" }, Modified: { format: "date-time", type: "string" }, RebalanceInstructionsId: { type: "string" }, IsPortfolioAssignable: { type: "boolean" }, RebalanceInstructions: { $ref: "#/definitions/Company.Model.Domain.RebalanceInstructions" } } }, Company.Model.Domain.RebalanceInstructions: { type: "object", properties: { Id: { type: "string" }, RebalanceInstructionType: { type: "string" } } }, System.Object: { type: "object", properties: { } }, Company.Model.Util.ReturnTypes.V1.Model: { required: [ "Id", "ModelType", "Name", "IsPortfolioAssignable" ], type: "object", properties: { ParentId: { type: "string" }, Id: { type: "string" }, ModelType: { type: "string", readOnly: true }, Name: { type: "string" }, Description: { type: "string" }, Target: { format: "double", maximum: 100, minimum: 0, type: "number" }, Rank: { type: "string" }, LowAlert: { format: "double", maximum: 100, minimum: -100, type: "number" }, HighAlert: { format: "double", maximum: 100, minimum: -100, type: "number" }, LowWarn: { format: "double", maximum: 100, minimum: -100, type: "number" }, HighWarn: { format: "double", maximum: 100, minimum: -100, type: "number" }, IsPortfolioAssignable: { type: "boolean" }, CreatedById: { type: "string" }, Created: { format: "date-time", type: "string" }, ModifiedById: { type: "string" }, Modified: { format: "date-time", type: "string" } } } } }

webron commented 9 years ago

Sorry, I wasn't clear. I meant the whole Swagger definition, not just the definitions section :)

mkrouwer commented 9 years ago

{ swagger: "2.0", info: { version: "v1", title: "Company.Model.Service" }, host: "my host", schemes: [ "https" ], paths: { /api/v0/Model: { get: { tags: [ "Model" ], operationId: "Model_Get", consumes: [ ], produces: [ "application/json", "text/json", "text/html", "application/xml", "text/xml" ], responses: { 200: { description: "OK", schema: { type: "array", items: { $ref: "#/definitions/Company.Model.Domain.Model" } } } }, deprecated: false } }, /api/v0/Portfolio/{portId}/UploadModel: { post: { tags: [ "Model" ], operationId: "Model_UploadModel", consumes: [ ], produces: [ "application/json", "text/json", "text/html" ], parameters: [ { name: "portId", in: "path", required: true, type: "string" }, { name: "modelXML", in: "query", required: true, type: "string" } ], responses: { 200: { description: "OK", schema: { $ref: "#/definitions/System.Object" } } }, deprecated: false } }, /api/v0/Portfolio/{portId}/AssignModel/{modelId}: { post: { tags: [ "Model" ], operationId: "Model_Assign", consumes: [ ], produces: [ "application/json", "text/json", "text/html" ], parameters: [ { name: "portId", in: "path", required: true, type: "string" }, { name: "modelId", in: "path", required: true, type: "string" } ], responses: { 200: { description: "OK", schema: { $ref: "#/definitions/System.Object" } } }, deprecated: false } }, /api/v1/Model: { get: { tags: [ "ModelV1" ], summary: "Retrieve all models", description: "Retrieves an array of all existing models", operationId: "ModelV1_ListAssignableModels", consumes: [ ], produces: [ "application/json", "text/json", "text/html", "application/xml", "text/xml" ], responses: { 200: { description: "OK", schema: { type: "array", items: { $ref: "#/definitions/Company.Model.Util.ReturnTypes.V1.Model" } } } }, deprecated: false }, put: { tags: [ "ModelV1" ], summary: "Creates a model", description: "Creates a model", operationId: "ModelV1_ChangeModel", consumes: [ "application/json", "text/json", "text/html", "application/xml", "text/xml" ], produces: [ "application/json", "text/json", "text/html", "application/xml", "text/xml" ], parameters: [ { name: "model", in: "body", required: true, schema: { $ref: "#/definitions/Company.Model.Util.ReturnTypes.V1.Model" } } ], responses: { 200: { description: "OK", schema: { $ref: "#/definitions/Company.Model.Util.ReturnTypes.V1.Model" } }, 400: { description: "Bad Request" } }, deprecated: false }, post: { tags: [ "ModelV1" ], summary: "Saves a model.", description: "Creates a model.", operationId: "ModelV1_PostModel", consumes: [ "application/json", "text/json", "text/html", "application/xml", "text/xml" ], produces: [ "application/json", "text/json", "text/html", "application/xml", "text/xml" ], parameters: [ { name: "model", in: "body", description: "The model to be saved.", required: true, schema: { $ref: "#/definitions/Company.Model.Util.ReturnTypes.V1.Model" } } ], responses: { 200: { description: "OK", schema: { $ref: "#/definitions/Company.Model.Util.ReturnTypes.V1.Model" } }, 400: { description: "Bad Request" } }, deprecated: false }, delete: { tags: [ "ModelV1" ], summary: "Deletes a model by GUID", description: "Deletes a model", operationId: "ModelV1_DeleteModel", consumes: [ "application/json", "text/json", "text/html", "application/xml", "text/xml" ], produces: [ "application/json", "text/json", "text/html", "application/xml", "text/xml" ], parameters: [ { name: "model", in: "body", required: true, schema: { $ref: "#/definitions/Company.Model.Util.ReturnTypes.V1.Model" } } ], responses: { 200: { description: "OK", schema: { $ref: "#/definitions/Company.Model.Util.ReturnTypes.V1.Model" } }, 404: { description: "Model Not Found" } }, deprecated: false } }, /api/v1/Model/{Id}: { get: { tags: [ "ModelV1" ], summary: "Retrieves a model by GUID", description: "Retrieves a model given a GUID", operationId: "ModelV1_GetModel", consumes: [ ], produces: [ "application/json", "text/json", "text/html", "application/xml", "text/xml" ], parameters: [ { name: "Id", in: "path", required: true, type: "string" } ], responses: { 200: { description: "OK", schema: { $ref: "#/definitions/Company.Model.Util.ReturnTypes.V1.Model" } }, 404: { description: "Model Not Found" } }, deprecated: false } }, /api/v1/Model/{Id}/expanded: { get: { tags: [ "ModelV1" ], summary: "Retrieves an expanded model by GUID", description: "Retrieves an expanded model given a GUID", operationId: "ModelV1_GetModelExpanded", consumes: [ ], produces: [ "application/json", "text/json", "text/html", "application/xml", "text/xml" ], parameters: [ { name: "Id", in: "path", required: true, type: "string" } ], responses: { 200: { description: "OK", schema: { type: "array", items: { $ref: "#/definitions/Company.Model.Util.ReturnTypes.V1.Model" } } }, 404: { description: "Model Not Found" } }, deprecated: false } }, /api/v1/Model/EraseDb: { get: { tags: [ "ModelV1" ], summary: "EndPoint to erase database.", operationId: "ModelV1_EraseDb", consumes: [ ], produces: [ "application/json", "text/json", "text/html", "application/xml", "text/xml" ], responses: { 200: { description: "OK", schema: { type: "boolean" } } }, deprecated: false } } }, definitions: { Company.Model.Domain.Model: { type: "object", properties: { ModelType: { type: "string" }, Id: { type: "string" }, Name: { type: "string" }, Description: { type: "string" }, Created: { format: "date-time", type: "string" }, CreatedById: { type: "string" }, CreatedBy: { $ref: "#/definitions/Company.Model.Domain.User" }, Modified: { format: "date-time", type: "string" }, ModifiedById: { type: "string" }, ModifiedBy: { $ref: "#/definitions/Company.Model.Domain.User" }, RebalanceInstructionsId: { type: "string" }, IsPortfolioAssignable: { type: "boolean" }, RebalanceInstructions: { $ref: "#/definitions/Company.Model.Domain.RebalanceInstructions" } } }, Company.Model.Domain.User: { type: "object", properties: { Name: { type: "string" }, Id: { type: "string" } } }, Company.Model.Domain.RebalanceInstructions: { type: "object", properties: { Id: { type: "string" }, RebalanceInstructionType: { type: "string" } } }, System.Object: { type: "object", properties: { } }, Company.Model.Util.ReturnTypes.V1.Model: { required: [ "Id", "ModelType", "Name", "IsPortfolioAssignable" ], type: "object", properties: { ParentId: { type: "string" }, Id: { type: "string" }, Created: { format: "date-time", type: "string" }, Modified: { format: "date-time", type: "string" }, ModelType: { type: "string", readOnly: true }, Name: { type: "string" }, Description: { type: "string" }, Target: { format: "double", maximum: 100, minimum: 0, type: "number" }, Rank: { type: "string" }, LowAlert: { format: "double", maximum: 100, minimum: -100, type: "number" }, HighAlert: { format: "double", maximum: 100, minimum: -100, type: "number" }, LowWarn: { format: "double", maximum: 100, minimum: -100, type: "number" }, HighWarn: { format: "double", maximum: 100, minimum: -100, type: "number" }, IsPortfolioAssignable: { type: "boolean" }, CreatedBy: { type: "string" }, ModifiedBy: { type: "string" } } } } }

mkrouwer commented 9 years ago

sorry for the length! >_< but this is the whole spec

webron commented 9 years ago

@mkrouwer - thanks, but that's not a valid JSON file. All the keys are missing quotes around there and it's difficult to format it and read it. Please submit a valid JSON so we can investigate it further.

fehguy commented 9 years ago

This has been fixed, you're all green now.

mattfrear commented 9 years ago

Thank you :+1: