Skip to content
This repository has been archived by the owner on Aug 4, 2023. It is now read-only.

v1.2 Semantic Validation #1

Closed
20 tasks done
whitlockjc opened this issue Jun 17, 2014 · 3 comments
Closed
20 tasks done

v1.2 Semantic Validation #1

whitlockjc opened this issue Jun 17, 2014 · 3 comments

Comments

@whitlockjc
Copy link
Member

We need to do more than just structural validation of the Swagger files:

***** The validation requires both the resource listing file and the API declaration/resource files

Errors

  • Ensure model ids are unique
  • Ensure model references point to defined models
  • Ensure model subTypes are not cyclical
  • Ensure model subTypes do not override inherited properties
  • Ensure model subTypes do not reference multiple "parent" objects (multiple inheritance)
  • Ensure model required properties actually exist on the model object
  • Ensure model discriminator property exists
  • Ensure API operation nicknames are unique (within a single apiDeclaration/resource)
  • Ensure API operation authorization references point to defined authorization *****
  • Ensure API operation authorization scopes (oauth 2 only) point to a defined scope *****
  • Ensure API operation method is unique
  • Ensure API operation responseMessages respond with unique response code
  • Ensure resource listing paths point to defined apiDeclaration/resource *****
  • Ensure the defaultValue of a parameter is within its type constraints

Warnings

  • Declared but unreferenced authorization *****
  • Declared but unreferenced authorization scope *****
  • Declared but unreferenced model
  • Duplicate entries for model subTypes
  • Mismatched Swagger version across an API *****
  • API operation summary is greater than 120 characters
@webron
Copy link

webron commented Jun 18, 2014

Regarding the defaultValue, the same would apply to minimum and/or maximum.
Another thing you can check regarding the defaultValue is that its type corresponds with the type+format fields. Not sure if the JSON Schema currently checks this, not sure if it can.

@whitlockjc
Copy link
Member Author

Thanks Ron, that helped a lot. I went back and updated the issue to reflect.

@whitlockjc
Copy link
Member Author

Based on what is known right now, this issue is complete. Please file bugs/enhancements related to semantic validation as new issues.

nelson-perez added a commit to nelson-perez/swagger-tools that referenced this issue Oct 9, 2017
When there is an array type that should strings and the first parameter is a valid number it converts to number instead of letting be string.
The culprit is that it is blindly calling JSON.Parse(value) will convert it into a single number the same will happen if we want a string and we get back an object.

This is an issue:
 apigee-127#1 Because there should be a string not whatever is been parsed by JSON
 apigee-127#2 If we apply a pattern to an array of "string" and the object it is not a string it will throw an exception of val.match() is not a function on:
  /swagger-tools/lib/validator.js @ line 441:    if (!_.isUndefined(pattern) && _.isNull(val.match(new RegExp(pattern)))) {

Throws the exception val.match is not a function.
nelson-perez added a commit to nelson-perez/swagger-tools that referenced this issue Oct 9, 2017
When there is an array type that should strings and the first parameter is a valid number it converts to number instead of letting be string.
The culprit is that it is blindly calling JSON.Parse(value) will convert it into a single number the same will happen if we want a string and we get back an object.

This is an issue:
 apigee-127#1 Because there should be a string not whatever is been parsed by JSON
 apigee-127#2 If we apply a pattern to an array of "string" and the object it is not a string it will throw an exception of val.match() is not a function on:
  /swagger-tools/lib/validator.js @ line 441:    if (!_.isUndefined(pattern) && _.isNull(val.match(new RegExp(pattern)))) {

Throws the exception val.match is not a function.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants