Example #1
0
        Dictionary <string, RefPropertyHolder> GetSubProperties(OpenApiRefResolver loader, JContainer container)
        {
            var refProps = container
                           .Descendants()
                           .OfType <JProperty>()
                           .Where(p => p.Name == Constants.REF_KEYWORD)
                           .ToList();

            return(refProps.Select(async refProp =>
            {
                var subValue = await loader.GetRefJTokenAsync(refProp.Value.ToString());
                refProp.Value = $"#/{subValue.PropertyType}/{subValue.PropertyName}";
                return subValue;
            })
                   .Select(x => x.Result).Where(x => x != null)
                   .GroupBy(x => x.PropertyName)
                   .Select(x => x.FirstOrDefault(y => y.PropertyValue != null))
                   .Where(x => x != null)
                   .ToDictionary(x => x.PropertyName, y => y));
        }
Example #2
0
        OpenApiRefResolver GetYamlLoader(RefInfo refInfo)
        {
            if (refInfo.IsNestedInThisDocument)
            {
                return(this);
            }

            if (refInfo.AbsoluteDocumentUri == DocumentUri)
            {
                return(this);
            }

            if (OtherResolvers.TryGetValue(refInfo.AbsoluteDocumentUri, out var loader))
            {
                return(loader);
            }

            loader = new OpenApiRefResolver(refInfo.AbsoluteDocumentUri, Authorization, OtherResolvers);
            OtherResolvers[refInfo.AbsoluteDocumentUri] = loader;
            return(loader);
        }