@@ -61,6 +61,9 @@ public Status execute(LightLambdaExchange exchange) {
6161 final NormalisedPath openApiPathString = maybeApiPath .get ();
6262 final Path path = helper .openApi3 .getPath (openApiPathString .original ());
6363
64+ /* populate the event with the path parameter values. */
65+ exchange .getRequest ().setPathParameters (this .getPathParamsMap (requestPath , openApiPathString ));
66+
6467 final String httpMethod = exchange .getRequest ().getHttpMethod ().toLowerCase ();
6568 final Operation operation = path .getOperation (httpMethod );
6669
@@ -85,6 +88,41 @@ public Status execute(LightLambdaExchange exchange) {
8588 return successMiddlewareStatus ();
8689 }
8790
91+ /**
92+ * Grabs the path parameters from the original path based on the provided specification path.
93+ *
94+ * @param original - The original path containing potential parameter values.
95+ * @param specPath - The specification path that contains potential parameter keys.
96+ * @return - returns a map containing the path parameter names and values.
97+ */
98+ private Map <String , String > getPathParamsMap (final NormalisedPath original , final NormalisedPath specPath ) {
99+
100+ if (!specPath .original ().contains ("{" )) {
101+ LOG .debug ("Provided path does not contain any path parameters." );
102+ return new HashMap <>();
103+
104+ } else if (original .parts ().size () != specPath .parts ().size ()) {
105+ LOG .warn ("Number of path parts in original does not match the specification." );
106+ return new HashMap <>();
107+ }
108+
109+ final var params = new HashMap <String , String >();
110+ final var originalParts = original .parts ();
111+ final var specParts = specPath .parts ();
112+
113+ for (int x = 0 ; x < original .parts ().size (); x ++) {
114+ final var specPart = specParts .get (x );
115+
116+ if (specPart .startsWith ("{" ) && specPart .endsWith ("}" )) {
117+ final var paramKey = specPart .substring (1 , specPart .length () - 1 );
118+ final var pathParamValue = originalParts .get (x );
119+ LOG .trace ("Specification path part {} with a key of {} and a value of {}" , x , paramKey , pathParamValue );
120+ params .put (paramKey , pathParamValue );
121+ }
122+ }
123+ return params ;
124+ }
125+
88126 /**
89127 * Validates the injectMap and openapiMap.Throws an exception if not valid.
90128 *
0 commit comments