Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add x-id-field to operation/path specs
  • Loading branch information
mohawk2 committed Dec 31, 2018
1 parent 6d5499d commit a988990
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/Mojolicious/Plugin/Yancy.pm
Expand Up @@ -585,6 +585,7 @@ sub _openapi_spec_infer_mojo {
@{ $op_spec->{parameters} || [] },
;
my ($id_field) = grep defined,
(map $_->{'x-id-field'}, $op_spec, $pathspec),
(@path_params && $path_params[-1]{name});
my %base_spec = (
controller => $api_controller,
Expand Down
10 changes: 7 additions & 3 deletions lib/Yancy/Help/Config.pod
Expand Up @@ -461,9 +461,13 @@ an error. To derive which collection, these things are considered:

Each operation infers from the HTTP method plus other information which
method of L<Yancy::Controller::Yancy::API> it should connect to.
The C<id_field> parameter is the C<name> of the last C<in: "path"> parameter
specified in the operation's spec. Every operation type except C<get>
in "list" mode, and C<post>, needs an C<id_field> parameter.

The C<id_field> stash parameter is either the value of the C<x-id-field>
key in the operation or path spec, or if not given, the C<name> of the
last C<in: "path"> parameter specified in the operation's spec. Every
operation type except C<get> in "list" mode, and C<post>, needs an
C<id_field> parameter. This is what the controller will pass as the C<id>
to the relevant L<Yancy::Backend> method.

=head1 Additional Configuration

Expand Down

0 comments on commit a988990

Please sign in to comment.