Example #1
0
        public override Object Clone()
        {
            var cloneCopy = new OpenApiQueryStringValidator(this._context);

            base.Copy(cloneCopy);
            return(cloneCopy);
        }
Example #2
0
        public override void AddRule(IValidate rule)
        {
            if (rule is OpenApiParameterRule)
            {
                var _openApiParameterRule = rule as OpenApiParameterRule;

                switch (_openApiParameterRule.InParameterLocation)
                {
                case ParameterLocation.Query:                           //Query = 0,
                    if (_queryValidator == null)
                    {
                        _queryValidator = new OpenApiQueryStringValidator(_validatorContext);
                    }
                    _queryValidator.AddRule(_openApiParameterRule);
                    break;

                case ParameterLocation.Header:                          //Header = 1,
                    if (_headerValidator == null)
                    {
                        _headerValidator = new OpenApiHeadersValidator(_validatorContext);
                    }
                    _headerValidator.AddRule(_openApiParameterRule);
                    break;

                case ParameterLocation.Path:                          //Path = 2,
                    if (_pathValidator == null)
                    {
                        _pathValidator = new OpenApiPathValidator(_validatorContext);
                    }
                    _pathValidator.AddRule(_openApiParameterRule);
                    break;

                case ParameterLocation.Cookie:                          //Cookie = 3
                    if (_cookiesValidator == null)
                    {
                        _cookiesValidator = new OpenApiCookiesValidator(_validatorContext);
                    }
                    _cookiesValidator.AddRule(_openApiParameterRule);
                    break;

                case null:
                    break;

                default:
                    break;
                }
            }
            else
            if (rule is OpenApiBodyValidator)
            {
                _bodyValidator = rule as OpenApiBodyValidator;
            }
        }