private OpenApiSchema VisitTypeReference(IEdmTypeReference reference) { OpenApiSchema schema = new OpenApiSchema(); switch (reference.TypeKind()) { case EdmTypeKind.Collection: schema.Type = "array"; schema.Items = VisitTypeReference(reference.AsCollection().ElementType()); break; case EdmTypeKind.Complex: case EdmTypeKind.Entity: case EdmTypeKind.EntityReference: case EdmTypeKind.Enum: schema.Reference = new OpenApiReference("#/components/schemas/" + reference.Definition.FullTypeName()); break; case EdmTypeKind.Primitive: if (reference.IsInt64()) { schema = new OpenApiSchema { Type = "integer", Format = "int64", Nullable = reference.IsNullable ? (bool?)true : null }; } else if (reference.IsDouble()) { schema = new OpenApiSchema { Type = "number", Format = "double" }; } else if (reference.IsDate() || reference.IsDateTimeOffset()) { schema = new OpenApiSchema { Type = "string", Format = "date-time" }; } else { schema.Type = reference.AsPrimitive().GetOpenApiDataType().GetCommonName(); schema.Nullable = reference.IsNullable ? (bool?)true : null; } break; case EdmTypeKind.TypeDefinition: throw Error.NotSupported("Not supported!"); case EdmTypeKind.None: default: return(null); } return(schema); }