private static OApiSchema?NormalToSchema(Type type) { type = FunctionCommand.UnwrapReturnType(type); if (type.IsArray) { return(new OApiSchema("array") { Items = NormalToSchema(type.GetElementType() !) });
private static OApiSchema NormalToSchema(Type type) { type = FunctionCommand.UnwrapReturnType(type); if (type.IsArray) { return(new OApiSchema { type = "array", items = NormalToSchema(type.GetElementType()) }); } if (type == typeof(bool)) { return(OApiSchema.FromBasic("boolean")); } else if (type == typeof(sbyte)) { return(OApiSchema.FromBasic("integer", "int8")); } else if (type == typeof(byte)) { return(OApiSchema.FromBasic("integer", "uint8")); } else if (type == typeof(short)) { return(OApiSchema.FromBasic("integer", "int16")); } else if (type == typeof(ushort)) { return(OApiSchema.FromBasic("integer", "uint16")); } else if (type == typeof(int)) { return(OApiSchema.FromBasic("integer", "int32")); } else if (type == typeof(uint)) { return(OApiSchema.FromBasic("integer", "uint32")); } else if (type == typeof(long)) { return(OApiSchema.FromBasic("integer", "int64")); } else if (type == typeof(ulong)) { return(OApiSchema.FromBasic("integer", "uint64")); } else if (type == typeof(float)) { return(OApiSchema.FromBasic("number", "float")); } else if (type == typeof(double)) { return(OApiSchema.FromBasic("number", "double")); } else if (type == typeof(TimeSpan)) { return(OApiSchema.FromBasic("string", "duration")); } else if (type == typeof(DateTime)) { return(OApiSchema.FromBasic("string", "date-time")); } else if (type == typeof(string)) { return(OApiSchema.FromBasic("string", null)); } else if (type == typeof(JsonEmpty) || type == typeof(void)) { return(null); } else if (type == typeof(JsonObject) || type == typeof(object) || type == typeof(ICommandResult)) { return(OApiSchema.FromBasic("object")); } else if (type == typeof(ICommand)) { return(OApiSchema.FromBasic("λ")); } else { return(OApiSchema.FromBasic(type.Name)); } }