Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make parsed parameters, body available to callers #66

Open
karenetheridge opened this issue Oct 26, 2023 · 2 comments
Open

make parsed parameters, body available to callers #66

karenetheridge opened this issue Oct 26, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@karenetheridge
Copy link
Owner

Now that we're supporting fancy parameter parsing (e.g. style=deepObject etc), it would be helpful for the application to not have to do the parsing all over again and just use the values that we parsed.

This could be passed back in the config hashref that is used in all methods:

my $request = Mojo::Message::Request->new->parse("GET http://localhost:4242/foo/123?filter[name]=Bob HTTP/1.1\n\n");
my $result = $openapi->validate_request($request, my $extra_data = {});
# now $extra_data looks like:
{
  path_template => '/foo/{foo_id}',
  path_captures => { foo_id => '123' },
  operation_id => ...,
  method => 'GET',
  operation_path => ...,
  request => ...,
  query_parameters => {
    filter => { name => 'Bob' },
  },
}

I don't know if there's a need to include headers in here as they are parsed very simply, and the rules do often change depending on the header. query parameters are the ones that are tricky here.

Perhaps we only want to do this on demand, or only when a special style is used.

@karenetheridge
Copy link
Owner Author

This would also be helpful when parsing multipart objects - the application can just use the hashref form that we already validated against the schema.

@karenetheridge karenetheridge added the enhancement New feature or request label Jul 13, 2024
@karenetheridge
Copy link
Owner Author

Perhaps we only want to do this on demand

We can do this by making the user pass a specific key in the $options hash - if it is present, we will populate/overwrite it with the parsed data, and otherwise we won't, because this will consume a lot of memory.

Also be mindful of memory leaks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant