private static async Task <EndpointDocCacheResult> GetCached(ConcurrentDictionary <string, JsonSchema4> cache, string groupName, string method, string relativePath, Type type, Func <Type, Task <JsonSchema4> > missCallback)
        {
            var key    = $"{groupName}|{method}|{relativePath}";
            var result = new EndpointDocCacheResult();

            result.FromCache = cache.TryGetValue(key, out var schema);
            if (!result.FromCache)
            {
                //This can potentially race if not defined.
                //However, there is no real downside to that, this is still nice and thread safe.
                schema = await missCallback.Invoke(type);

                if (schema == null || schema.IsCacheableDoc())
                {
                    //If the schema is null or cacheable, add it to the cache, null values will count as coming from the cache
                    schema           = cache.GetOrAdd(key, schema);
                    result.FromCache = true; //This is now technically from the cache too
                }
            }
            result.Schema = schema;

            return(result);
        }
 public void SetResponseSchema(EndpointDocCacheResult cacheResult)
 {
     this.ResponseSchema          = cacheResult.Schema;
     this.ResponseSchemaFromCache = cacheResult.FromCache;
 }