Esempio n. 1
0
        /// <summary>Writes the specified writer.</summary>
        /// <param name="writer">The writer.</param>
        /// <param name="specVersion">The spec version.</param>
        public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
        {
            writer.WriteStartObject();

            writer.WriteProperty("name", this.enumType.Name);
            writer.WriteProperty("modelAsString", this.enumModeling == OasEnumModeling.AsString);
            writer.WritePropertyName("values");

            var items = Enum.GetValues(enumType);

            writer.WriteStartArray();

            foreach (var item in items)
            {
                var summary = OasDocHelpers.GetFieldDocumentationSummary(enumType, item.ToString(), this.commentDocs);

                writer.WriteStartObject();

                writer.WriteProperty("value", this.namingPolicy.ConvertName(item.ToString()));
                writer.WriteProperty("name", this.namingPolicy.ConvertName(item.ToString()));

                if (!string.IsNullOrWhiteSpace(summary))
                {
                    writer.WriteProperty("description", summary);
                }

                writer.WriteEndObject();
            }

            writer.WriteEndArray();
            writer.WriteEndObject();
        }
    public void Write(IOpenApiWriter writer)
    {
        writer.WriteStartObject();

        if (!string.IsNullOrWhiteSpace(Credentials))
        {
            writer.WriteProperty("credentials", Credentials);
        }

        writer.WritePropertyName("responses");
        {
            writer.WriteStartObject();
            writer.WritePropertyName("default");
            {
                writer.WriteStartObject();
                writer.WriteProperty("statusCode", "200");
                writer.WriteEndObject();
            }
            writer.WriteEndObject();
        }

        writer.WriteProperty("uri", LambdaUri);
        writer.WriteProperty("passthroughBehavior", "when_no_templates");
        writer.WriteProperty("httpMethod", HttpMethod);
        writer.WriteProperty("type", "aws");
        writer.WriteEndObject();
    }
Esempio n. 3
0
        /// <summary>
        /// Serialize to OpenAPI V2 document without using reference.
        /// </summary>
        public void SerializeAsV2WithoutReference(IOpenApiWriter writer)
        {
            writer.WriteStartObject();

            // description
            writer.WriteRequiredProperty(OpenApiConstants.Description, Description);

            var extensionsClone = new Dictionary <string, IOpenApiExtension>(Extensions);

            if (Content != null)
            {
                var mediatype = Content.FirstOrDefault();
                if (mediatype.Value != null)
                {
                    // schema
                    writer.WriteOptionalObject(
                        OpenApiConstants.Schema,
                        mediatype.Value.Schema,
                        (w, s) => s.SerializeAsV2(w));

                    // examples
                    if (Content.Values.Any(m => m.Example != null))
                    {
                        writer.WritePropertyName(OpenApiConstants.Examples);
                        writer.WriteStartObject();

                        foreach (var mediaTypePair in Content)
                        {
                            if (mediaTypePair.Value.Example != null)
                            {
                                writer.WritePropertyName(mediaTypePair.Key);
                                writer.WriteAny(mediaTypePair.Value.Example);
                            }
                        }

                        writer.WriteEndObject();
                    }

                    writer.WriteExtensions(mediatype.Value.Extensions, OpenApiSpecVersion.OpenApi2_0);

                    foreach (var key in mediatype.Value.Extensions.Keys)
                    {
                        // The extension will already have been serialized as part of the call above,
                        // so remove it from the cloned collection so we don't write it again.
                        extensionsClone.Remove(key);
                    }
                }
            }

            // headers
            writer.WriteOptionalMap(OpenApiConstants.Headers, Headers, (w, h) => h.SerializeAsV2(w));

            // extension
            writer.WriteExtensions(extensionsClone, OpenApiSpecVersion.OpenApi2_0);

            writer.WriteEndObject();
        }
        /// <summary>
        /// Serialize to OpenAPI V2 document without using reference.
        /// </summary>
        public void SerializeAsV2WithoutReference(IOpenApiWriter writer)
        {
            if (Type == SecuritySchemeType.Http && Scheme != OpenApiConstants.Basic)
            {
                // Bail because V2 does not support non-basic HTTP scheme
                writer.WriteStartObject();
                writer.WriteEndObject();
                return;
            }

            if (Type == SecuritySchemeType.OpenIdConnect)
            {
                // Bail because V2 does not support OpenIdConnect
                writer.WriteStartObject();
                writer.WriteEndObject();
                return;
            }

            writer.WriteStartObject();

            // type
            switch (Type)
            {
            case SecuritySchemeType.Http:
                writer.WriteProperty(OpenApiConstants.Type, OpenApiConstants.Basic);
                break;

            case SecuritySchemeType.OAuth2:
                // These properties apply to ouauth2 type only.
                // flow
                // authorizationUrl
                // tokenUrl
                // scopes
                writer.WriteProperty(OpenApiConstants.Type, Type.GetDisplayName());
                WriteOAuthFlowForV2(writer, Flows);
                break;

            case SecuritySchemeType.ApiKey:
                // These properties apply to apiKey type only.
                // name
                // in
                writer.WriteProperty(OpenApiConstants.Type, Type.GetDisplayName());
                writer.WriteProperty(OpenApiConstants.Name, Name);
                writer.WriteProperty(OpenApiConstants.In, In.GetDisplayName());
                break;
            }

            // description
            writer.WriteProperty(OpenApiConstants.Description, Description);

            // extensions
            writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi2_0);

            writer.WriteEndObject();
        }
 private void Write(IOpenApiWriter writer, object value)
 {
     if (value is string s)
     {
         writer.WriteValue(s);
     }
     else if (value is IList <object> l)
     {
         writer.WriteStartArray();
         foreach (var o in l)
         {
             Write(writer, o);
         }
         writer.WriteEndArray();
     }
     else if (value is IDictionary <object, object> d)
     {
         writer.WriteStartObject();
         foreach (var o in d)
         {
             Write(writer, o);
         }
         writer.WriteEndObject();
     }
     else if (value is KeyValuePair <object, object> kvp)
     {
         writer.WritePropertyName((string)kvp.Key);
         Write(writer, kvp.Value);
     }
     else
     {
         throw new NotSupportedException($"Value: {value}");
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Serialize <see cref="OpenApiOAuthFlows"/> to Open Api v3.0
        /// </summary>
        public void SerializeAsV3(IOpenApiWriter writer)
        {
            if (writer == null)
            {
                throw Error.ArgumentNull(nameof(writer));
            }

            writer.WriteStartObject();

            // implicit
            writer.WriteOptionalObject(OpenApiConstants.Implicit, Implicit, (w, o) => o.SerializeAsV3(w));

            // password
            writer.WriteOptionalObject(OpenApiConstants.Password, Password, (w, o) => o.SerializeAsV3(w));

            // clientCredentials
            writer.WriteOptionalObject(
                OpenApiConstants.ClientCredentials,
                ClientCredentials,
                (w, o) => o.SerializeAsV3(w));

            // authorizationCode
            writer.WriteOptionalObject(
                OpenApiConstants.AuthorizationCode,
                AuthorizationCode,
                (w, o) => o.SerializeAsV3(w));

            // extensions
            writer.WriteExtensions(Extensions);

            writer.WriteEndObject();
        }
Esempio n. 7
0
        /// <summary>
        /// Serialize <see cref="OpenApiInfo"/> to Open Api v3.0
        /// </summary>
        public void SerializeAsV3(IOpenApiWriter writer)
        {
            if (writer == null)
            {
                throw Error.ArgumentNull(nameof(writer));
            }

            writer.WriteStartObject();

            // title
            writer.WriteProperty(OpenApiConstants.Title, Title);

            // description
            writer.WriteProperty(OpenApiConstants.Description, Description);

            // termsOfService
            writer.WriteProperty(OpenApiConstants.TermsOfService, TermsOfService?.OriginalString);

            // contact object
            writer.WriteOptionalObject(OpenApiConstants.Contact, Contact, (w, c) => c.SerializeAsV3(w));

            // license object
            writer.WriteOptionalObject(OpenApiConstants.License, License, (w, l) => l.SerializeAsV3(w));

            // version
            writer.WriteProperty(OpenApiConstants.Version, Version);

            // specification extensions
            writer.WriteExtensions(Extensions);

            writer.WriteEndObject();
        }
Esempio n. 8
0
        /// <summary>
        /// Serialize inline PathItem in OpenAPI V2
        /// </summary>
        /// <param name="writer"></param>
        public void SerializeAsV2WithoutReference(IOpenApiWriter writer)
        {
            writer.WriteStartObject();

            // operations except "trace"
            foreach (var operation in Operations)
            {
                if (operation.Key != OperationType.Trace)
                {
                    writer.WriteOptionalObject(
                        operation.Key.GetDisplayName(),
                        operation.Value,
                        (w, o) => o.SerializeAsV2(w));
                }
            }

            // parameters
            writer.WriteOptionalCollection(OpenApiConstants.Parameters, Parameters, (w, p) => p.SerializeAsV2(w));

            // write "summary" as extensions
            writer.WriteProperty(OpenApiConstants.ExtensionFieldNamePrefix + OpenApiConstants.Summary, Summary);

            // write "description" as extensions
            writer.WriteProperty(
                OpenApiConstants.ExtensionFieldNamePrefix + OpenApiConstants.Description,
                Description);

            // specification extensions
            writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi2_0);

            writer.WriteEndObject();
        }
        private void WriteInternal(IOpenApiWriter writer)
        {
            // { for JSON, empty for YAML
            writer.WriteStartObject();

            // operationRef
            writer.WriteOptionalProperty(OpenApiConstants.OpenApiDocOperationRef, OperationRef);

            // operationId
            writer.WriteOptionalProperty(OpenApiConstants.OpenApiDocOperationId, OperationId);

            // parameters
            writer.WriteOptionalDictionary(OpenApiConstants.OpenApiDocParameters, Parameters);

            // requestBody
            writer.WriteOptionalObject(OpenApiConstants.OpenApiDocRequestBody, RequestBody);

            // description
            writer.WriteOptionalProperty(OpenApiConstants.OpenApiDocDescription, Description);

            // server
            writer.WriteOptionalObject(OpenApiConstants.OpenApiDocServer, Server);

            // specification extensions
            writer.WriteDictionary(Extensions);

            // } for JSON, empty for YAML
            writer.WriteEndObject();
        }
Esempio n. 10
0
        /// <summary>
        /// Write Open API server object.
        /// </summary>
        /// <param name="writer">The Open API Writer.</param>
        public virtual void Write(IOpenApiWriter writer)
        {
            if (writer == null)
            {
                throw Error.ArgumentNull("writer");
            }

            // { for JSON, empty for YAML
            writer.WriteStartObject();

            // name
            writer.WriteRequiredProperty(OpenApiConstants.OpenApiDocUrl, Url.OriginalString);

            // description
            writer.WriteOptionalProperty(OpenApiConstants.OpenApiDocDescription, Description);

            // variables
            writer.WriteOptionalDictionary(OpenApiConstants.OpenApiDocVariables, Variables);

            // specification extensions
            writer.WriteDictionary(Extensions);

            // } for JSON, empty for YAML
            writer.WriteEndObject();
        }
        /// <summary>
        /// Write Any object to the given writer.
        /// </summary>
        /// <param name="writer">The writer.</param>
        public void Write(IOpenApiWriter writer)
        {
            if (writer == null)
            {
                throw Error.ArgumentNull("writer");
            }

            // { for json, empty for YAML
            writer.WriteStartObject();

            foreach (var item in this)
            {
                writer.WritePropertyName(item.Key);

                IOpenApiWritable writerElement = item.Value as IOpenApiWritable;
                if (writerElement != null)
                {
                    writerElement.Write(writer);
                }
                else
                {
                    writer.WriteValue(item.Value);
                }
            }

            // } for json, empty for YAML
            writer.WriteEndObject();
        }
    /// <inheritdoc />
    public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
    {
        if (writer == null)
        {
            throw new ArgumentNullException(nameof(writer));
        }

        if (RemovalDate.HasValue || Date.HasValue || !string.IsNullOrEmpty(Version) || !string.IsNullOrEmpty(Description))
        {
            writer.WriteStartObject();

            if (RemovalDate.HasValue)
            {
                writer.WriteProperty(nameof(RemovalDate).ToFirstCharacterLowerCase(), RemovalDate.Value);
            }
            if (Date.HasValue)
            {
                writer.WriteProperty(nameof(Date).ToFirstCharacterLowerCase(), Date.Value);
            }
            if (!string.IsNullOrEmpty(Version))
            {
                writer.WriteProperty(nameof(Version).ToFirstCharacterLowerCase(), Version);
            }
            if (!string.IsNullOrEmpty(Description))
            {
                writer.WriteProperty(nameof(Description).ToFirstCharacterLowerCase(), Description);
            }

            writer.WriteEndObject();
        }
    }
        /// <summary>
        /// Write Open API tag object.
        /// </summary>
        /// <param name="writer">The Open API Writer.</param>
        public virtual void Write(IOpenApiWriter writer)
        {
            if (writer == null)
            {
                throw Error.ArgumentNull("writer");
            }

            // { for JSON, empty for YAML
            writer.WriteStartObject();

            // name
            writer.WriteRequiredProperty(OpenApiConstants.OpenApiDocName, Name);

            // description
            writer.WriteOptionalProperty(OpenApiConstants.OpenApiDocDescription, Description);

            // External Docs
            writer.WriteOptionalObject(OpenApiConstants.OpenApiDocExternalDocs, ExternalDocs);

            // specification extensions
            writer.WriteDictionary(Extensions);

            // } for JSON, empty for YAML
            writer.WriteEndObject();
        }
Esempio n. 14
0
        /// <summary>
        /// Write Any object to the given writer.
        /// </summary>
        /// <param name="writer">The writer.</param>
        public void Write(IOpenApiWriter writer)
        {
            if (writer == null)
            {
                throw Error.ArgumentNull("writer");
            }

            // { for json, empty for YAML
            writer.WriteStartObject();

            // description
            writer.WriteOptionalProperty(OpenApiConstants.OpenApiDocDescription, Description);

            // content
            writer.WriteRequiredDictionary(OpenApiConstants.OpenApiDocContent, Content);

            // required
            writer.WriteOptionalProperty(OpenApiConstants.OpenApiDocRequired, Required);

            // specification extensions
            writer.WriteDictionary(Extensions);

            // } for json, empty for YAML
            writer.WriteEndObject();
        }
Esempio n. 15
0
        /// <summary>
        /// Serialize <see cref="OpenApiReference"/> to Open Api v2.0.
        /// </summary>
        public void SerializeAsV2(IOpenApiWriter writer)
        {
            if (writer == null)
            {
                throw Error.ArgumentNull(nameof(writer));
            }

            if (Type == ReferenceType.Tag)
            {
                // Write the string value only
                writer.WriteValue(ReferenceV2);
                return;
            }

            if (Type == ReferenceType.SecurityScheme)
            {
                // Write the string as property name
                writer.WritePropertyName(ReferenceV2);
                return;
            }

            writer.WriteStartObject();

            // $ref
            writer.WriteProperty(OpenApiConstants.DollarRef, ReferenceV2);

            writer.WriteEndObject();
        }
        /// <summary>
        /// Write Open API Contact object to the given writer.
        /// </summary>
        /// <param name="writer">The writer.</param>
        public virtual void Write(IOpenApiWriter writer)
        {
            if (writer == null)
            {
                throw Error.ArgumentNull("writer");
            }

            // { for json, empty for YAML
            writer.WriteStartObject();

            // name
            writer.WriteOptionalProperty(OpenApiConstants.OpenApiDocName, Name);

            // url
            writer.WriteOptionalProperty(OpenApiConstants.OpenApiDocUrl, Url?.OriginalString);

            // email
            writer.WriteOptionalProperty(OpenApiConstants.OpenApiDocEmail, Email);

            // specification extensions
            writer.WriteDictionary(Extensions);

            // } for json, empty for YAML
            writer.WriteEndObject();
        }
        /// <summary>
        /// Write Encoding object to the given writer.
        /// </summary>
        /// <param name="writer">The writer.</param>
        public void Write(IOpenApiWriter writer)
        {
            if (writer == null)
            {
                throw Error.ArgumentNull("writer");
            }

            // { for json, empty for YAML
            writer.WriteStartObject();

            // contentType
            writer.WriteOptionalProperty(OpenApiConstants.OpenApiDocContentType, ContentType);

            // headers
            writer.WriteOptionalDictionary(OpenApiConstants.OpenApiDocHeaders, Headers);

            // style
            writer.WriteOptionalProperty(OpenApiConstants.OpenApiDocStyle, Style?.ToString());

            // explode
            writer.WriteOptionalProperty(OpenApiConstants.OpenApiDocExplode, Explode);

            // allowReserved
            writer.WriteOptionalProperty(OpenApiConstants.OpenApiDocAllowReserved, AllowReserved);

            // specification extensions
            writer.WriteDictionary(Extensions);

            // } for json, empty for YAML
            writer.WriteEndObject();
        }
Esempio n. 18
0
        private void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
        {
            if (writer == null)
            {
                throw Error.ArgumentNull(nameof(writer));
            }

            writer.WriteStartObject();

            // name
            writer.WriteProperty(OpenApiConstants.Name, Name);

            // namespace
            writer.WriteProperty(OpenApiConstants.Namespace, Namespace?.AbsoluteUri);

            // prefix
            writer.WriteProperty(OpenApiConstants.Prefix, Prefix);

            // attribute
            writer.WriteProperty(OpenApiConstants.Attribute, Attribute, false);

            // wrapped
            writer.WriteProperty(OpenApiConstants.Wrapped, Wrapped, false);

            // extensions
            writer.WriteExtensions(Extensions, specVersion);

            writer.WriteEndObject();
        }
Esempio n. 19
0
        /// <summary>
        /// Serialize <see cref="OpenApiMediaType"/> to Open Api v3.0.
        /// </summary>
        public void SerializeAsV3(IOpenApiWriter writer)
        {
            if (writer == null)
            {
                throw Error.ArgumentNull(nameof(writer));
            }

            writer.WriteStartObject();

            // schema
            writer.WriteOptionalObject(OpenApiConstants.Schema, Schema, (w, s) => s.SerializeAsV3(w));

            // example
            writer.WriteOptionalObject(OpenApiConstants.Example, Example, (w, e) => w.WriteAny(e));

            // examples
            writer.WriteOptionalMap(OpenApiConstants.Examples, Examples, (w, e) => e.SerializeAsV3(w));

            // encoding
            writer.WriteOptionalMap(OpenApiConstants.Encoding, Encoding, (w, e) => e.SerializeAsV3(w));

            // extensions
            writer.WriteExtensions(Extensions);

            writer.WriteEndObject();
        }
        /// <summary>
        /// Write Open API Info to the given writer.
        /// </summary>
        /// <param name="writer">The writer.</param>
        public virtual void Write(IOpenApiWriter writer)
        {
            if (writer == null)
            {
                throw Error.ArgumentNull("writer");
            }

            // { for json, empty for YAML
            writer.WriteStartObject();

            // title
            writer.WriteRequiredProperty(OpenApiConstants.OpenApiDocTitle, Title);

            // description
            writer.WriteOptionalProperty(OpenApiConstants.OpenApiDocDescription, Description);

            // termsOfService
            writer.WriteOptionalProperty(OpenApiConstants.OpenApiDocTermsOfService, TermsOfService?.OriginalString);

            // contact object
            writer.WriteOptionalObject(OpenApiConstants.OpenApiDocContact, Contact);

            // license object
            writer.WriteOptionalObject(OpenApiConstants.OpenApiDocLicense, License);

            // version
            writer.WriteRequiredProperty(OpenApiConstants.OpenApiDocVersion, Version?.ToString());

            // specification extensions
            writer.WriteDictionary(Extensions);

            // } for json, empty for YAML
            writer.WriteEndObject();
        }
Esempio n. 21
0
        /// <summary>
        /// Serialize <see cref="OpenApiExternalDocs"/> to Open Api v3.0.
        /// </summary>
        public void SerializeAsV3(IOpenApiWriter writer)
        {
            if (writer == null)
            {
                throw Error.ArgumentNull("writer");
            }

            writer.WriteStartObject();

            // contentType
            writer.WriteProperty(OpenApiConstants.ContentType, ContentType);

            // headers
            writer.WriteOptionalMap(OpenApiConstants.Headers, Headers, (w, h) => h.SerializeAsV3(w));

            // style
            writer.WriteProperty(OpenApiConstants.Style, Style?.GetDisplayName());

            // explode
            writer.WriteProperty(OpenApiConstants.Explode, Explode, false);

            // allowReserved
            writer.WriteProperty(OpenApiConstants.AllowReserved, AllowReserved, false);

            // extensions
            writer.WriteExtensions(Extensions);

            writer.WriteEndObject();
        }
Esempio n. 22
0
 public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
 {
     writer.WriteStartObject();
     writer.WriteProperty("page", PageParameterName);
     writer.WriteProperty("pageSize", PageSizeParameterName);
     writer.WriteEndObject();
 }
Esempio n. 23
0
        /// <summary>
        /// Serialize <see cref="OpenApiPathItem"/> to Open Api v3.0
        /// </summary>
        public void SerializeAsV3(IOpenApiWriter writer)
        {
            if (writer == null)
            {
                throw Error.ArgumentNull(nameof(writer));
            }

            writer.WriteStartObject();

            // summary
            writer.WriteProperty(OpenApiConstants.Summary, Summary);

            // description
            writer.WriteProperty(OpenApiConstants.Description, Description);

            // operations
            foreach (var operation in Operations)
            {
                writer.WriteOptionalObject(
                    operation.Key.GetDisplayName(),
                    operation.Value,
                    (w, o) => o.SerializeAsV3(w));
            }

            // servers
            writer.WriteOptionalCollection(OpenApiConstants.Servers, Servers, (w, s) => s.SerializeAsV3(w));

            // parameters
            writer.WriteOptionalCollection(OpenApiConstants.Parameters, Parameters, (w, p) => p.SerializeAsV3(w));

            // specification extensions
            writer.WriteExtensions(Extensions);

            writer.WriteEndObject();
        }
Esempio n. 24
0
        private void WriteInternal(IOpenApiWriter writer)
        {
            Debug.Assert(writer != null);

            // { for json, empty for YAML
            writer.WriteStartObject();

            // description
            writer.WriteRequiredProperty(OpenApiConstants.OpenApiDocDescription, Description);

            // headers
            writer.WriteOptionalDictionary(OpenApiConstants.OpenApiDocHeaders, Headers);

            // content
            writer.WriteOptionalDictionary(OpenApiConstants.OpenApiDocContent, Content);

            // headers
            writer.WriteOptionalDictionary(OpenApiConstants.OpenApiDocLinks, Links);

            // Extensions
            writer.WriteDictionary(Extensions);

            // } for json, empty for YAML
            writer.WriteEndObject();
        }
Esempio n. 25
0
        /// <summary>
        /// Serialize inline PathItem in OpenAPI V3
        /// </summary>
        /// <param name="writer"></param>
        public void SerializeAsV3WithoutReference(IOpenApiWriter writer)
        {
            writer.WriteStartObject();

            // summary
            writer.WriteProperty(OpenApiConstants.Summary, Summary);

            // description
            writer.WriteProperty(OpenApiConstants.Description, Description);

            // operations
            foreach (var operation in Operations)
            {
                writer.WriteOptionalObject(
                    operation.Key.GetDisplayName(),
                    operation.Value,
                    (w, o) => o.SerializeAsV3(w));
            }

            // servers
            writer.WriteOptionalCollection(OpenApiConstants.Servers, Servers, (w, s) => s.SerializeAsV3(w));

            // parameters
            writer.WriteOptionalCollection(OpenApiConstants.Parameters, Parameters, (w, p) => p.SerializeAsV3(w));

            // specification extensions
            writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi3_0);

            writer.WriteEndObject();
        }
 public void Write(IOpenApiWriter writer)
 {
     writer.WriteStartObject();
     writer.WriteProperty("baz", Baz);
     writer.WriteProperty("bar", Bar);
     writer.WriteEndObject();
 }
Esempio n. 27
0
        /// <summary>
        /// Write Any object to the given writer.
        /// </summary>
        /// <param name="writer">The writer.</param>
        public void Write(IOpenApiWriter writer)
        {
            if (writer == null)
            {
                throw Error.ArgumentNull("writer");
            }

            // { for json, empty for YAML
            writer.WriteStartObject();

            // authorizationUrl
            writer.WriteOptionalProperty(OpenApiConstants.OpenApiDocAuthorizationUrl, AuthorizationUrl?.OriginalString);

            // tokenUrl
            writer.WriteOptionalProperty(OpenApiConstants.OpenApiDocTokenUrl, TokenUrl?.OriginalString);

            // refreshUrl
            writer.WriteOptionalProperty(OpenApiConstants.OpenApiDocRefreshUrl, RefreshUrl?.OriginalString);

            // scopes
            writer.WriteOptionalDictionary(OpenApiConstants.OpenApiDocScopes, Scopes);

            // specification extensions
            writer.WriteDictionary(Extensions);

            // } for json, empty for YAML
            writer.WriteEndObject();
        }
        /// <summary>
        /// Write Any object to the given writer.
        /// </summary>
        /// <param name="writer">The writer.</param>
        public void Write(IOpenApiWriter writer)
        {
            if (writer == null)
            {
                throw Error.ArgumentNull("writer");
            }

            // { for json, empty for YAML
            writer.WriteStartObject();

            // implicit
            writer.WriteOptionalObject(OpenApiConstants.OpenApiDocImplicit, Implicit);

            // password
            writer.WriteOptionalObject(OpenApiConstants.OpenApiDocPassword, Password);

            // clientCredentials
            writer.WriteOptionalObject(OpenApiConstants.OpenApiDocClientCredentials, ClientCredentials);

            // authorizationCode
            writer.WriteOptionalObject(OpenApiConstants.OpenApiDocAuthorizationCode, AuthorizationCode);

            // specification extensions
            writer.WriteDictionary(Extensions);

            // } for json, empty for YAML
            writer.WriteEndObject();
        }
Esempio n. 29
0
 public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
 {
     writer.WriteStartObject();
     writer.WriteProperty("baz", Baz);
     writer.WriteProperty("bar", Bar);
     writer.WriteEndObject();
 }
Esempio n. 30
0
 public virtual void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
 {
     writer.WriteStartObject();
     WriteBody(writer, specVersion);
     writer.WriteOptionalMap("children", Children, specVersion);
     writer.WriteEndObject();
 }