New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.2 Semantic Validation #1

Closed
whitlockjc opened this Issue Jun 17, 2014 · 3 comments

Comments

Projects
None yet
2 participants
@whitlockjc
Member

whitlockjc commented Jun 17, 2014

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

This comment has been minimized.

Show comment
Hide comment
@webron

webron 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.

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

This comment has been minimized.

Show comment
Hide comment
@whitlockjc

whitlockjc Jun 19, 2014

Member

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

Member

whitlockjc commented Jun 19, 2014

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

@whitlockjc

This comment has been minimized.

Show comment
Hide comment
@whitlockjc

whitlockjc Jul 11, 2014

Member

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

Member

whitlockjc commented Jul 11, 2014

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

@whitlockjc whitlockjc closed this Jul 11, 2014

nelson-perez added a commit to nelson-perez/swagger-tools that referenced this issue Oct 9, 2017

Handle array of string when numbers are present
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:
 #1 Because there should be a string not whatever is been parsed by JSON
 #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

Handle numbers or objects when it is an array of strings
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:
 #1 Because there should be a string not whatever is been parsed by JSON
 #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 join this conversation on GitHub. Already have an account? Sign in to comment