public static string GetDisplayNameV3(OpenApiReferenceType type) { switch (type) { case (OpenApiReferenceType.Callback): return("callbacks"); case (OpenApiReferenceType.Example): return("examples"); case (OpenApiReferenceType.Header): return("headers"); case (OpenApiReferenceType.Link): return("links"); case (OpenApiReferenceType.Parameter): return("parameters"); case (OpenApiReferenceType.RequestBody): return("requestBodies"); case (OpenApiReferenceType.Response): return("responses"); case (OpenApiReferenceType.Schema): return("schemas"); case (OpenApiReferenceType.SecurityScheme): return("securitySchemes"); case (OpenApiReferenceType.Tag): return("tags"); default: return(null); } }
public OpenApiReference CreateReference(OpenApiReferenceType type, string refLink) { if (string.IsNullOrWhiteSpace(refLink)) { throw new ArgumentNullException(); } var segments = refLink.Split('#'); if (segments.Length == 1 && (type == OpenApiReferenceType.Tag || type == OpenApiReferenceType.SecurityScheme)) { return(new OpenApiReference { Type = type, Id = refLink }); } else if (segments.Length == 2) { if (!refLink.StartsWith("#")) { throw new NotImplementedException("External references not yet supported"); } var pathSegments = segments[1].Split('/'); if (pathSegments.Length == 4 && pathSegments[1] == "components") { var reference = GetReferenceType(pathSegments[2]); return(new OpenApiReference { Type = reference, Id = pathSegments[3] }); } } throw new ArgumentException("Invalid reference link"); }
public static string GetDisplayNameV2(OpenApiReferenceType type) { switch (type) { case (OpenApiReferenceType.Schema): return("definitions"); case (OpenApiReferenceType.Parameter): return("parameters"); case (OpenApiReferenceType.Response): return("responses"); case (OpenApiReferenceType.Header): return("headers"); case (OpenApiReferenceType.Tag): return("tags"); case (OpenApiReferenceType.SecurityScheme): return("securityDefinitions"); default: return(null); } }