### Is there an existing issue for this?

- [X] I have searched the existing issues

### Current Behavior

When defining path parameter resources, for example:

 * `/documents/{documentId+}`
 * `/documents/search`

In CDK, the order of definition changes what LocalStack returns. If you define the path parameter `/documents/{documentId+}` before `/documents/search` and then try to hit `/documents/search`, LocalStack instead invokes the integration for `/documents/{documentId+}`, rather than the intended one.

However, if you define `/documents/search` before `/documents/{documentId+}` in CDK, LocalStack invokes the correct integration.

### Expected Behavior

In AWS, the order does not matter, and no matter which order they're defined in trying to hit `/document/search` will result in the integration for that resource being invokes.

### How are you starting LocalStack?

With a docker-compose file

### Steps To Reproduce

#### How are you starting localstack (e.g., `bin/localstack` command, arguments, or `docker-compose.yml`)

    docker run localstack/localstack

#### Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)

```ts
export class GatewayStack extends Stack {
  constructor(scope: Construct, id: string, props: StackProps) {
    super(scope, id, props);

    const api = new RestApi(this, "test-api", {
      restApiName: "test-api",
    });

    const getByIdLambda = new Function(this, "get-by-id-handler", {
      runtime: Runtime.NODEJS_20_X,
      code: Code.fromInline(
        "exports.handler = async () => ({ statusCode: 200, body: 'Get By Id' });",
      ),
      handler: "index.handler",
    });

    const searchLambda = new Function(this, "search-lambda-handler", {
      runtime: Runtime.NODEJS_20_X,
      code: Code.fromInline(
        "exports.handler = async () => ({ statusCode: 200, body: 'Search Results' });",
      ),
      handler: "index.handler",
    });

    const documents = api.root.addResource("document");
    const getById = documents.addResource("{documentId+}");
    const search = documents.addResource("search");

    getById.addMethod("GET", new LambdaIntegration(getByIdLambda));
    search.addMethod("GET", new LambdaIntegration(searchLambda));
  }
}
```

```sh
GATEWAY_ID=$(awslocal apigateway get-rest-apis --query "items[0].id" --output text)
curl https://$GATEWAY_ID.execute-api.localhost.localstack.cloud:4566/prod/document/search
```

### Environment

```markdown
- OS: Ubuntu 20.04
- LocalStack: 3.1
```


### Anything else?

I've reproduced the issue here: https://github.com/Garethp/localstack-bugs/tree/order-dependant-path-parts
If you clone down the branch `order-dependant-path-parts`, run `yarn install` and then `./start.sh` you should see the issue in action
):
                    
                    LOG.warning(
                        "A validator ('%s') was referenced for %s.(%s), but is not defined",
                        request_validator_name,
                        rel_path,
                        method_name,
                    )
                method_resource.request_validator_id = req_validator_id
            
            resource_path_part = parts[-1].strip("/")
            if is_variable_path(resource_path_part) and not is_greedy_path(resource_path_part):
                path_parameter = resource_path_part[1:-1]  
                request_parameters[f"method.request.path.{path_parameter}"] = True
            method_resource.request_parameters = request_parameters or None
            
            method_responses = field_schema.get("responses", {})
            for method_status_code, method_response in method_responses.items():
                method_response_model = None
                model_ref = None
                
                if "schema" in method_response:  
                    model_ref = method_response["schema"].get("$ref")
                elif "content" in method_response:  
                    for content_type, media_type in method_response["content"].items():
                        
                        
                        if content_type == APPLICATION_JSON:
                            model_ref = media_type.get("schema", {}).get("$ref")
                            continue