示例#1
0
 /// <summary>
 /// Creates a new instance of the <see cref="Operation"/> class.
 /// </summary>
 /// <param name="tags">The list of tags for API documentation control.</param>
 /// <param name="summary">The short summary of what the operation does.</param>
 /// <param name="description">The verbose explanation of the operation behavior.</param>
 /// <param name="externalDocumentation">The additional external documentation for this operation.</param>
 /// <param name="operationIdentifier">The unique string used to identify the operation.</param>
 /// <param name="parameters">The list of parameters that are applicable for this operation.</param>
 /// <param name="requestBody">The request body applicable for this operation.</param>
 /// <param name="responses">The list of possible responses as they are returned from executing this operation.</param>
 /// <param name="callbacks">The map of possible out-of band callbacks related to the parent operation.</param>
 /// <param name="options">The flags that indicate what options are set on the operation.</param>
 /// <param name="security">The declaration of which security mechanisms can be used for this operation.</param>
 /// <param name="servers">The alternative server list to service this operation.</param>
 public Operation(
     IReadOnlyList <string> tags = default,
     string summary     = default,
     string description = default,
     ExternalDocumentation externalDocumentation = default,
     string operationIdentifier = default,
     IReadOnlyDictionary <ParameterKey, Referable <ParameterBody> > parameters = default,
     Referable <RequestBody> requestBody = default,
     IReadOnlyDictionary <ResponseKey, Referable <Response> > responses = default,
     IReadOnlyDictionary <string, Referable <Callback> > callbacks      = default,
     OperationOptions options = default,
     IReadOnlyList <SecurityScheme> security = default,
     IReadOnlyList <Server> servers          = default)
 {
     Tags                  = tags ?? Array.Empty <string>();
     Summary               = summary;
     Description           = description;
     ExternalDocumentation = externalDocumentation;
     OperationIdentifier   = operationIdentifier;
     Parameters            = parameters ?? ReadOnlyDictionary.Empty <ParameterKey, Referable <ParameterBody> >();
     RequestBody           = requestBody;
     Responses             = responses ?? ReadOnlyDictionary.Empty <ResponseKey, Referable <Response> >();
     Callbacks             = callbacks ?? ReadOnlyDictionary.Empty <string, Referable <Callback> >();
     Options               = options;
     Security              = security ?? Array.Empty <SecurityScheme>();
     Servers               = servers ?? Array.Empty <Server>();
 }
示例#2
0
 /// <summary>
 /// Creates a new instance of the <see cref="SchemaBuilder"/> class.
 /// </summary>
 /// <param name="value">The <see cref="Schema"/> to copy values from.</param>
 public SchemaBuilder(Schema value)
 {
     if (value is null)
     {
         throw new ArgumentNullException(nameof(value));
     }
     JsonType              = value.JsonType;
     Format                = value.Format;
     Title                 = value.Title;
     Description           = value.Description;
     NumberRange           = value.NumberRange;
     ItemsRange            = value.ItemsRange;
     LengthRange           = value.LengthRange;
     PropertiesRange       = value.PropertiesRange;
     Options               = value.Options;
     Pattern               = value.Pattern;
     Enum                  = new List <ScalarValue>(value.Enum);
     AllOf                 = new List <Referable <Schema> >(value.AllOf);
     OneOf                 = new List <Referable <Schema> >(value.OneOf);
     AnyOf                 = new List <Referable <Schema> >(value.AnyOf);
     Not                   = new List <Referable <Schema> >(value.Not);
     Items                 = value.Items;
     Properties            = new Dictionary <string, Referable <Schema> >(value.Properties);
     AdditionalProperties  = new Dictionary <string, Referable <Schema> >(value.AdditionalProperties);
     ExternalDocumentation = value.ExternalDocumentation;
 }
示例#3
0
        /// <summary>Indicates whether the current object is equal to another object of the same type.</summary>
        /// <param name="other">An object to compare with this object.</param>
        /// <returns>true if the current object is equal to the <paramref name="other">other</paramref> parameter; otherwise, false.</returns>
        public bool Equals(OasSchema other)
        {
            if (other is null) return false;
            if (ReferenceEquals(this, other)) return true;

            if (JsonType != other.JsonType) return false;
            if (Format != other.Format) return false;
            if (Options != other.Options) return false;
            if (!NumberRange.Equals(other.NumberRange)) return false;
            if (!ItemsRange.Equals(other.ItemsRange)) return false;
            if (!LengthRange.Equals(other.LengthRange)) return false;
            if (!PropertiesRange.Equals(other.PropertiesRange)) return false;
            if (!ExternalDocumentation.Equals(other.ExternalDocumentation)) return false;
            if (!StringComparer.Ordinal.Equals(Title, other.Title)) return false;
            if (!StringComparer.Ordinal.Equals(Description, other.Description)) return false;
            if (!StringComparer.Ordinal.Equals(Pattern, other.Pattern)) return false;
            if (!Enum.NullableSetEquals(other.Enum)) return false;
            if (!AllOf.NullableSetEquals(other.AllOf)) return false;
            if (!OneOf.NullableSetEquals(other.OneOf)) return false;
            if (!AnyOf.NullableSetEquals(other.AnyOf)) return false;
            if (!Not.NullableSetEquals(other.Not)) return false;
            if (Items != other.Items) return false;
            if (!Properties.NullableDictionaryEquals(other.Properties)) return false;
            if (!AdditionalProperties.NullableDictionaryEquals(other.AdditionalProperties)) return false;

            return true;
        }
示例#4
0
 /// <summary>
 /// Creates a new instance of the <see cref="Tag"/> class.
 /// </summary>
 /// <param name="name">The name of the tag.</param>
 /// <param name="description">The short description for the tag.</param>
 /// <param name="externalDocumentation">The additional external documentation for the tag.</param>
 public Tag(
     string name        = default,
     string description = default,
     ExternalDocumentation externalDocumentation = default)
 {
     Name                  = name;
     Description           = description;
     ExternalDocumentation = externalDocumentation;
 }
示例#5
0
 /// <summary>
 /// Creates a new instance of the <see cref="TagBuilder"/> class.
 /// </summary>
 /// <param name="value">The <see cref="Tag"/> to copy values from.</param>
 public TagBuilder(Tag value)
 {
     if (value is null)
     {
         throw new ArgumentNullException(nameof(value));
     }
     Name                  = value.Name;
     Description           = value.Description;
     ExternalDocumentation = value.ExternalDocumentation;
 }
示例#6
0
 /// <summary>
 /// Creates a new instance of the <see cref="DocumentBuilder"/> class.
 /// </summary>
 /// <param name="value">The <see cref="Document"/> to copy values from.</param>
 public DocumentBuilder(Document value)
 {
     if (value is null)
     {
         throw new ArgumentNullException(nameof(value));
     }
     Version               = value.Version;
     Info                  = value.Info;
     Servers               = new List <Server>(value.Servers);
     Paths                 = new Dictionary <string, Referable <Path> >(value.Paths);
     Components            = value.Components;
     Security              = new List <Referable <SecurityScheme> >(value.Security);
     Tags                  = new List <Tag>(value.Tags);
     ExternalDocumentation = value.ExternalDocumentation;
 }
示例#7
0
        /// <summary>Returns the hash code for this instance.</summary>
        /// <returns>A 32-bit signed integer that is the hash code for this instance.</returns>
        public override int GetHashCode()
        {
            unchecked
            {
                var hc = 17L;

                hc = (hc * 23) + JsonType.GetHashCode();
                hc = (hc * 23) + Options.GetHashCode();
                hc = (hc * 23) + NumberRange.GetHashCode();
                hc = (hc * 23) + ItemsRange.GetHashCode();
                hc = (hc * 23) + LengthRange.GetHashCode();
                hc = (hc * 23) + PropertiesRange.GetHashCode();
                if (ExternalDocumentation != null)
                {
                    hc = (hc * 23) + ExternalDocumentation.GetHashCode();
                }
                if (Title != null)
                {
                    hc = (hc * 23) + StringComparer.Ordinal.GetHashCode(Title);
                }
                if (Format != null)
                {
                    hc = (hc * 23) + StringComparer.Ordinal.GetHashCode(Format);
                }
                if (Description != null)
                {
                    hc = (hc * 23) + StringComparer.Ordinal.GetHashCode(Description);
                }
                if (Pattern != null)
                {
                    hc = (hc * 23) + StringComparer.Ordinal.GetHashCode(Pattern);
                }
                hc = (hc * 23) + Enum.Count;
                hc = (hc * 23) + AllOf.Count;
                hc = (hc * 23) + OneOf.Count;
                hc = (hc * 23) + AnyOf.Count;
                hc = (hc * 23) + Not.Count;
                hc = (hc * 23) + Items.GetHashCode();
                hc = (hc * 23) + Properties.Count;
                hc = (hc * 23) + AdditionalProperties.Count;

                return(((int)(hc >> 32)) ^ (int)hc);
            }
        }
示例#8
0
 /// <summary>
 /// Creates a new instance of the <see cref="Document"/> class.
 /// </summary>
 /// <param name="version">The semantic version number of the OpenAPI Specification version that the OpenAPI document uses. The default is 3.0.0.</param>
 /// <param name="info">The metadata about the API.</param>
 /// <param name="servers">The list of <see cref="Server"/> instances, which provide connectivity information to a target server.</param>
 /// <param name="paths">The available paths and operations for the API.</param>
 /// <param name="components">The list that holds various schemas for the specification.</param>
 /// <param name="security">The declaration of which security mechanisms can be used across the API.</param>
 /// <param name="tags">The list of tags used by the specification with additional metadata.</param>
 /// <param name="externalDocumentation">The external documentation.</param>
 public Document(
     SemanticVersion?version        = default,
     Information info               = default,
     IReadOnlyList <Server> servers = default,
     IReadOnlyDictionary <string, Referable <Path> > paths = default,
     Components components = default,
     IReadOnlyList <Referable <SecurityScheme> > security = default,
     IReadOnlyList <Tag> tags = default,
     ExternalDocumentation externalDocumentation = default)
 {
     Version               = version ?? new SemanticVersion(3, 0, 0);
     Info                  = info;
     Servers               = servers ?? Array.Empty <Server>();
     Paths                 = paths ?? ReadOnlyDictionary.Empty <string, Referable <Path> >();
     Components            = components;
     Security              = security ?? Array.Empty <Referable <SecurityScheme> >();
     Tags                  = tags ?? Array.Empty <Tag>();
     ExternalDocumentation = externalDocumentation;
 }
示例#9
0
 /// <summary>
 /// Creates a new <see cref="Schema"/> value.
 /// </summary>
 /// <param name="type">The general type of the schema.</param>
 /// <param name="format">The specific type of the schema/</param>
 /// <param name="title">The title of the schema.</param>
 /// <param name="description">The description of the schema.</param>
 /// <param name="numberRange">The range of valid numbers.</param>
 /// <param name="itemsRange">The range of valid item counts.</param>
 /// <param name="lengthRange">The range of valid lengths.</param>
 /// <param name="propertiesRange">The range of valid property counts.</param>
 /// <param name="options">The schema options.</param>
 /// <param name="pattern">The regex validation for string values.</param>
 /// <param name="enum">The valid enum values.</param>
 /// <param name="allOf">The list of schemas that this schema must conform to.</param>
 /// <param name="oneOf">The list of schemas that, from which exactly one, this schema must conform to.</param>
 /// <param name="anyOf">The list of schemas that, from which one or more, this schema must conform to.</param>
 /// <param name="not">The list of schemas that this schema must not conform to.</param>
 /// <param name="items">The list of schemas that represent the array items that this schema must contain.</param>
 /// <param name="properties">The list of valid properties.</param>
 /// <param name="additionalProperties">The list of valid properties for children.</param>
 /// <param name="externalDocumentation">The external documentation.</param>
 public Schema(
     SchemaType type                           = default,
     string format                             = null,
     string title                              = null,
     string description                        = null,
     NumberRange numberRange                   = default,
     CountRange itemsRange                     = default,
     CountRange lengthRange                    = default,
     CountRange propertiesRange                = default,
     SchemaOptions options                     = default,
     string pattern                            = default,
     IReadOnlyList <ScalarValue> @enum         = default,
     IReadOnlyList <Referable <Schema> > allOf = default,
     IReadOnlyList <Referable <Schema> > oneOf = default,
     IReadOnlyList <Referable <Schema> > anyOf = default,
     IReadOnlyList <Referable <Schema> > not   = default,
     Referable <Schema> items                  = default,
     IReadOnlyDictionary <string, Referable <Schema> > properties           = default,
     IReadOnlyDictionary <string, Referable <Schema> > additionalProperties = default,
     ExternalDocumentation externalDocumentation = default)
 {
     JsonType              = type;
     Title                 = title;
     Format                = format;
     Description           = description;
     NumberRange           = numberRange;
     ItemsRange            = itemsRange;
     LengthRange           = lengthRange;
     PropertiesRange       = propertiesRange;
     Options               = options;
     Pattern               = pattern;
     Enum                  = @enum ?? Array.Empty <ScalarValue>();
     AllOf                 = allOf ?? Array.Empty <Referable <Schema> >();
     OneOf                 = oneOf ?? Array.Empty <Referable <Schema> >();
     AnyOf                 = anyOf ?? Array.Empty <Referable <Schema> >();
     Not                   = not ?? Array.Empty <Referable <Schema> >();
     Items                 = items;
     Properties            = properties ?? Dictionary.ReadOnlyEmpty <string, Referable <Schema> >();
     AdditionalProperties  = additionalProperties ?? Dictionary.ReadOnlyEmpty <string, Referable <Schema> >();
     ExternalDocumentation = externalDocumentation;
 }
示例#10
0
        /// <summary>Indicates whether the current object is equal to another object of the same type.</summary>
        /// <param name="other">An object to compare with this object.</param>
        /// <returns>true if the current object is equal to the <paramref name="other">other</paramref> parameter; otherwise, false.</returns>
        public virtual bool Equals(OasOperation other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            if (!Tags.NullableSetEquals(other.Tags))
            {
                return(false);
            }
            if (!StringComparer.Ordinal.Equals(Summary, other.Summary))
            {
                return(false);
            }
            if (!StringComparer.Ordinal.Equals(Description, other.Description))
            {
                return(false);
            }
            if (!ExternalDocumentation.NullableEquals(other.ExternalDocumentation))
            {
                return(false);
            }
            if (!StringComparer.Ordinal.Equals(OperationIdentifier, other.OperationIdentifier))
            {
                return(false);
            }
            if (!Parameters.NullableDictionaryEquals(other.Parameters))
            {
                return(false);
            }
            if (!RequestBody.Equals(other.RequestBody))
            {
                return(false);
            }
            if (!Responses.NullableDictionaryEquals(other.Responses))
            {
                return(false);
            }
            if (!Callbacks.NullableDictionaryEquals(other.Callbacks))
            {
                return(false);
            }
            if (Options != other.Options)
            {
                return(false);
            }
            if (!Security.NullableSetEquals(other.Security))
            {
                return(false);
            }
            if (!Servers.NullableListEquals(other.Servers))
            {
                return(false);
            }

            return(true);
        }