/// <summary> /// Serializes a <see cref="OasParameterBody"/> value into an existing <see cref="JObject"/> instance. /// </summary> /// <param name="value">The <see cref="OasParameterBody"/> value to serialize.</param> /// <param name="json">The <see cref="JObject"/> to populate.</param> protected virtual void SerializeParameterBody(OasParameterBody value, JObject json) { if (value == null) { return; } var examples = value.Examples .Select(x => ValueTuple.Create(x.Key?.ToString(), x.Value)); var content = value.Content .Select(x => ValueTuple.Create(x.Key?.ToString(), x.Value)); SetJsonValue(json, PathConstants.Description, value.Description); SetJsonFlag(json, PathConstants.Required, value.Options, OasParameterOptions.Required); SetJsonFlag(json, PathConstants.Deprecated, value.Options, OasParameterOptions.Deprecated); SetJsonFlag(json, PathConstants.AllowEmptyValue, value.Options, OasParameterOptions.AllowEmptyValue); SetJsonValue(json, PathConstants.Style, ToJsonValue(value.Style)); SetJsonFlag(json, PathConstants.Explode, value.Options, OasParameterOptions.Explode); SetJsonFlag(json, PathConstants.AllowReserved, value.Options, OasParameterOptions.AllowReserved); SetJsonObject(json, PathConstants.Schema, value.Schema); SetJsonMap(json, PathConstants.Examples, examples); SetJsonMap(json, PathConstants.Content, content); }
/// <summary> /// Serializes a <see cref="OasParameterBody"/> value. /// </summary> /// <param name="value">The <see cref="OasParameterBody"/> value to serialize.</param> /// <returns>The <see cref="JToken"/>.</returns> protected virtual JToken SerializeParameterBody(OasParameterBody value) { if (value is null) { return(null); } var json = new JObject(); SerializeParameterBody(value, json); return(json); }
/// <summary> /// Serializes a <see cref="OasParameter"/> value according to its components. /// </summary> /// <param name="key">The <see cref="OasParameterKey"/> component to serialize.</param> /// <param name="value">The <see cref="OasParameterBody"/> component to serialize.</param> /// <returns>The <see cref="JToken"/>.</returns> protected virtual JToken SerializeParameter(OasParameterKey key, OasParameterBody value) { if (value is null) { return(null); } var json = new JObject(); SetJsonValue(json, PathConstants.Name, key.Name, true); SetJsonValue(json, PathConstants.In, ToJsonValue(key.Location)); SerializeParameterBody(value, json); return(json); }