public string GetExampleBody(string path, string contentType, string method) { Uri effectivePath = GetEffectivePath(path); string rootRelativePath = effectivePath.LocalPath.Substring(BaseAddress.LocalPath.Length).TrimStart('/'); IDirectoryStructure structure = SwaggerStructure?.TraverseTo(rootRelativePath); return(structure?.RequestInfo?.GetRequestBodyForContentType(contentType, method)); }
public IEnumerable <string> GetApplicableContentTypes(string method, string path) { Uri effectivePath = GetEffectivePath(path); string rootRelativePath = effectivePath.LocalPath.Substring(BaseAddress.LocalPath.Length).TrimStart('/'); IDirectoryStructure structure = SwaggerStructure?.TraverseTo(rootRelativePath); IReadOnlyDictionary <string, IReadOnlyList <string> > contentTypesByMethod = structure?.RequestInfo?.ContentTypesByMethod; if (contentTypesByMethod != null) { if (method is null) { return(contentTypesByMethod.Values.SelectMany(x => x).Distinct(StringComparer.OrdinalIgnoreCase)); } if (contentTypesByMethod.TryGetValue(method, out IReadOnlyList <string> contentTypes)) { return(contentTypes); } } return(null); }