Skip to content

[C#] Not full Validation method #4338

@aleksei-saharov

Description

@aleksei-saharov

Hi, all

I found some problems with Validation method.
For YAML:

definitions:
  Parameter:
    type: object
    required:
      - Value
      - ArrayValue
    properties:
      Value:
        type: integer
        minimum: 3
        maximum: 5
      ArrayValue:
        type: array
        minItems: 3
        maxItems: 5
        items:
          type: integer

Validation method:

public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        { 
            // Value (int?) maximum
            if(this.Value > (int?)5.0)
            {
                yield return new ValidationResult("Invalid value for Value, must be a value less than or equal to 5.0.", new [] { "Value" });
            }

            // Value (int?) minimum
            if(this.Value < (int?)3.0)
            {
                yield return new ValidationResult("Invalid value for Value, must be a value greater than or equal to 3.0.", new [] { "Value" });
            }

            yield break;
        }

There is no:

  1. Check properties for null (properties are required!)
  2. There is no minItems, maxItems validation !

PS: Our company use full PAID SwaggerHub subscription and we do not interested in using any branches or somethins else. Only stable Web SwaggerHub interface!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions