public bool TryWriteValue(IOpenApiWriter writer, JSchema schema) { switch (schema.GetSchemaType()) { case OpenApiSchemaType.Null: writer.WriteNull(); return(true); case OpenApiSchemaType.Boolean: writer.WriteValue(true); return(true); case OpenApiSchemaType.Integer: writer.WriteValue(GetIntValue(schema)); return(true); case OpenApiSchemaType.Number: var rawValue = GetNumberValue(schema).ToString("F", CultureInfo.InvariantCulture); writer.WriteRaw(rawValue); return(true); case OpenApiSchemaType.String: case OpenApiSchemaType.Object: case OpenApiSchemaType.Array: case OpenApiSchemaType.Any: case OpenApiSchemaType.Combined: return(false); default: throw new ArgumentOutOfRangeException(); } }
public bool TryWriteValue(IOpenApiWriter writer, JSchema schema) { if (ShouldWrite != null && !ShouldWrite(schema)) { return(false); } writer.WriteRaw(Value); return(true); }
public static void WriteJToken(this IOpenApiWriter writer, JToken token) { // ReSharper disable once SwitchStatementMissingSomeCases switch (token.Type) { case JTokenType.String: case JTokenType.Date: case JTokenType.Guid: case JTokenType.TimeSpan: case JTokenType.Uri: writer.WriteValue(token.ToString()); break; default: writer.WriteRaw(token.ToString()); break; } }
public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion) { writer.WriteRaw("[ { \"name\": \"Quick Start\", \"tags\": [\"Introduction\",\"FooBar\", \"ImportMarkup\"] }, { \"name\": \"API\", \"tags\": [\"Customers\"] } ]"); }
/// <inheritdoc/> public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion) { writer.WriteRaw(Value); }
/// <summary> /// Write out content of primitive element /// </summary> /// <param name="writer"></param> /// <param name="specVersion"></param> public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion) { switch (this.PrimitiveType) { case PrimitiveType.Integer: var intValue = (OpenApiInteger)(IOpenApiPrimitive)this; writer.WriteValue(intValue.Value); break; case PrimitiveType.Long: var longValue = (OpenApiLong)(IOpenApiPrimitive)this; writer.WriteValue(longValue.Value); break; case PrimitiveType.Float: var floatValue = (OpenApiFloat)(IOpenApiPrimitive)this; writer.WriteValue(floatValue.Value); break; case PrimitiveType.Double: var doubleValue = (OpenApiDouble)(IOpenApiPrimitive)this; writer.WriteValue(doubleValue.Value); break; case PrimitiveType.String: var stringValue = (OpenApiString)(IOpenApiPrimitive)this; if (stringValue.IsRawString()) { writer.WriteRaw(stringValue.Value); } else { writer.WriteValue(stringValue.Value); } break; case PrimitiveType.Byte: var byteValue = (OpenApiByte)(IOpenApiPrimitive)this; if (byteValue.Value == null) { writer.WriteNull(); } else { writer.WriteValue(Convert.ToBase64String(byteValue.Value)); } break; case PrimitiveType.Binary: var binaryValue = (OpenApiBinary)(IOpenApiPrimitive)this; if (binaryValue.Value == null) { writer.WriteNull(); } else { writer.WriteValue(Encoding.UTF8.GetString(binaryValue.Value)); } break; case PrimitiveType.Boolean: var boolValue = (OpenApiBoolean)(IOpenApiPrimitive)this; writer.WriteValue(boolValue.Value); break; case PrimitiveType.Date: var dateValue = (OpenApiDate)(IOpenApiPrimitive)this; writer.WriteValue(dateValue.Value); break; case PrimitiveType.DateTime: var dateTimeValue = (OpenApiDateTime)(IOpenApiPrimitive)this; writer.WriteValue(dateTimeValue.Value); break; case PrimitiveType.Password: var passwordValue = (OpenApiPassword)(IOpenApiPrimitive)this; writer.WriteValue(passwordValue.Value); break; default: throw new OpenApiWriterException( string.Format( SRResource.PrimitiveTypeNotSupported, this.PrimitiveType)); } }
public bool TryWriteValue(IOpenApiWriter writer, JSchema schema) { writer.WriteRaw("{\"mock\": true}"); return(true); }
public bool TryWriteValue(IOpenApiWriter writer, JSchema schema) { writer.WriteRaw("test"); return(true); }