Ejemplo n.º 1
0
        private void WriteInternal(IOpenApiWriter writer)
        {
            Debug.Assert(writer != null);

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

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

            // in
            writer.WriteRequiredProperty(OpenApiConstants.OpenApiDocIn, In.ToString());

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

            // required
            if (In == ParameterLocation.path)
            {
                writer.WriteRequiredProperty(OpenApiConstants.OpenApiDocRequired, true);
            }
            else
            {
                writer.WriteBooleanProperty(OpenApiConstants.OpenApiDocRequired, Required, false);
            }

            // deprecated
            writer.WriteBooleanProperty(OpenApiConstants.OpenApiDocDeprecated, Deprecated, false);

            // allowEmptyValue
            writer.WriteBooleanProperty(OpenApiConstants.OpenApiDocDeprecated, AllowEmptyValue, false);

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

            // explode
            writer.WriteBooleanProperty(OpenApiConstants.OpenApiDocExplode, Explode, false);

            // allowReserved
            writer.WriteBooleanProperty(OpenApiConstants.OpenApiDocAllowReserved, AllowReserved, false);

            // schema
            writer.WriteOptionalObject(OpenApiConstants.OpenApiDocSchema, Schema);

            // example
            writer.WriteOptionalObject(OpenApiConstants.OpenApiDocExample, Example);

            // examples
            writer.WriteOptionalDictionary(OpenApiConstants.OpenApiDocExamples, Examples);

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

            // specification extensions
            writer.WriteDictionary(Extensions);

            // } for json, empty for YAML
            writer.WriteEndObject();
        }