Beispiel #1
0
        /// <summary>
        /// Construct a Swagger object. 
        /// </summary>
        /// <param name="safe">If true, all properties are given none-null values. If false, only Required properties are populated. </param>
        public Swagger(bool safe)
        {
            if (safe)
            {
                Version = "2.0";
                Host = "localhost";
                BasePath = "/";

                Schemes = new string[1] { "http" };
                Consumes = new string[0];
                Produces = new string[0];

                ExternalDocs = new ExternalDocumentationObject();
                Info = new InfoObject();
                Contact = new ContactObject();
                License = new LicenseObject();
                Tags = new TagObject[0];
            }
            else
            {
                Version = "2.0";

                Info = new InfoObject(safe);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Constructor. 
        /// </summary>
        /// <param name="safe">If true, all values are given a non-</param>
        public TagObject(bool safe)
        {
            if (safe)
            {
                Name = "";
                Description = "";
                ExternalDocs = new ExternalDocumentationObject();
            }
            else
            {

            }
        }
Beispiel #3
0
        /// <summary>
        /// Validates the ExternalDocs property. No external Docs property is actually required; so null is an acceptable value. 
        /// </summary>
        /// <param name="value"></param>
        /// <param name="context"></param>
        /// <param name="level"></param>
        /// <param name="description"></param>
        /// <param name="result"></param>
        public static void ValidateExternalDocs(ExternalDocumentationObject value, string context, string description, string urlDescription, ViolationCollection result)
        {
            if (value == null) return;

            var externalDocsValid = (value != null);
            if (!externalDocsValid)
            {
                result.Add(new Violation() { Code = context, ViolationLevel = ViolationLevel.Informational, Context = context, Description = description });
            }
            else
            {
                // swagger.ExternalDocs is not null.
                if (value.Description == null) result.Add(new Violation() { Code = string.Format("{0}.Description", context), ViolationLevel = ViolationLevel.Informational, Context = string.Format("{0}.Description", context), Description = urlDescription });

                ValidateRequiredUrl(value.Url, string.Format("{0}.Url", context), ViolationLevel.Error, urlDescription, result);
            }
        }
Beispiel #4
0
 /// <summary>
 /// Validate an external docs object. 
 /// </summary>
 /// <param name="value"></param>
 /// <param name="context"></param>
 /// <param name="result"></param>
 public static void ValidateExternalDocs(ExternalDocumentationObject value, string context, ViolationCollection result)
 {
     ValidateExternalDocs(value, context, @"Allows referencing an external resource for extended documentation.", @"Required. The URL for the target documentation. Value MUST be in the format of a URL", result);
 }