Beispiel #1
0
        private static string RenderRelativeRefsForPathHelper(EndpointMethodMetadata endpointMethodMetadata, List <OpenApiParameter> allRouteParameters, List <OpenApiParameter> badRouteParameters, bool useForBadRequest)
        {
            var route = endpointMethodMetadata.Route;

            if (endpointMethodMetadata.ContractParameter == null)
            {
                return(route);
            }

            string relativeRefPath = RenderRelativeRefPath(route, allRouteParameters, badRouteParameters, endpointMethodMetadata.ComponentsSchemas, useForBadRequest);

            if (allRouteParameters.Count == 0)
            {
                return(relativeRefPath);
            }

            var queryRequiredParameters = endpointMethodMetadata.GetQueryRequiredParameters();

            if (queryRequiredParameters.Count == 0)
            {
                return(relativeRefPath);
            }

            string relativeRefQuery = RenderRelativeRefQuery(queryRequiredParameters, endpointMethodMetadata.ComponentsSchemas, false);

            return($"{relativeRefPath}{relativeRefQuery}");
        }
Beispiel #2
0
        private static List <string> RenderRelativeRefsForQuery(EndpointMethodMetadata endpointMethodMetadata, bool useForBadRequest = false)
        {
            var renderRelativeRefs = new List <string>();

            var queryRequiredParameters = endpointMethodMetadata.GetQueryRequiredParameters();

            if (queryRequiredParameters.Count == 0)
            {
                if (!useForBadRequest)
                {
                    // Create without queryParameters
                    renderRelativeRefs.Add(RenderRelativeRefsForQueryHelper(endpointMethodMetadata, null, useForBadRequest));
                }
            }
            else
            {
                var queryParameters = endpointMethodMetadata.GetQueryParameters();
                var combinationOfQueryParameters = ParameterCombinationHelper.GetCombination(queryParameters, useForBadRequest);
                foreach (var parameters in combinationOfQueryParameters)
                {
                    renderRelativeRefs.Add(RenderRelativeRefsForQueryHelper(endpointMethodMetadata, parameters, useForBadRequest));
                }
            }

            return(renderRelativeRefs);
        }