build/parse_spec_base_8.pl [67:134]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub process {
#===================================
    my ( $name, $defn ) = @_;
    my %spec;
   
    # body
    if ( my $body = $defn->{body} ) {
        $spec{body}
            = $body->{required}
            ? { required => 1 }
            : {};
        if ( $body->{serialize} && $body->{serialize} eq 'bulk' ) {
            $spec{serialize} = 'bulk';
        }
    }
    
    # url->paths is an array from ES 7.4
    # choose the first HTTP method from intersection of all the paths 
    my @methods = ();
    foreach (@{$defn->{url}->{paths}}) {
        if (scalar @methods == 0) {
            @methods = @{$_->{methods}};
        } else {
            @methods = intersect(@methods, @{$_->{methods}});
        }
    }

    # method
    my $method = $spec{method} = $methods[0];
    delete $spec{method} if $method eq 'GET';

    my @urls = ();
    my %parts = ();
    # arrange $defn->{url} with the previous format with ES < 7.4
    foreach (@{$defn->{url}->{paths}}) {
        push @urls, $_->{path};
        if ($_->{parts}) {
            while(my ($key, $value) = each(%{$_->{parts}})) { 
                $parts{$key} = $value
            }
        }
    }

    # paths
    my %url;
    $url{paths} = \@urls;
    $url{parts} = \%parts;
    
    $spec{paths} = process_paths( $name, $method, \%url );

    # parts
    my $parts = $spec{parts} = process_parts( $url{parts} );

    # filter path
    my %qs = ( %Common, process_qs( $defn->{params} ) );
    for ( keys %$parts ) {
        delete $qs{$_};
    }

    $spec{qs} = \%qs;

    # doc
    if ( $defn->{documentation}->{url} ) {
        $spec{doc} = $defn->{documentation}->{url} =~ m{/([^/]+)\.html$} ? $1 : '';
    }
    
    return \%spec;
}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



build/parse_spec_base_74.pl [67:134]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub process {
#===================================
    my ( $name, $defn ) = @_;
    my %spec;
   
    # body
    if ( my $body = $defn->{body} ) {
        $spec{body}
            = $body->{required}
            ? { required => 1 }
            : {};
        if ( $body->{serialize} && $body->{serialize} eq 'bulk' ) {
            $spec{serialize} = 'bulk';
        }
    }
    
    # url->paths is an array from ES 7.4
    # choose the first HTTP method from intersection of all the paths 
    my @methods = ();
    foreach (@{$defn->{url}->{paths}}) {
        if (scalar @methods == 0) {
            @methods = @{$_->{methods}};
        } else {
            @methods = intersect(@methods, @{$_->{methods}});
        }
    }

    # method
    my $method = $spec{method} = $methods[0];
    delete $spec{method} if $method eq 'GET';

    my @urls = ();
    my %parts = ();
    # arrange $defn->{url} with the previous format with ES < 7.4
    foreach (@{$defn->{url}->{paths}}) {
        push @urls, $_->{path};
        if ($_->{parts}) {
            while(my ($key, $value) = each(%{$_->{parts}})) { 
                $parts{$key} = $value
            }
        }
    }

    # paths
    my %url;
    $url{paths} = \@urls;
    $url{parts} = \%parts;
    
    $spec{paths} = process_paths( $name, $method, \%url );

    # parts
    my $parts = $spec{parts} = process_parts( $url{parts} );

    # filter path
    my %qs = ( %Common, process_qs( $defn->{params} ) );
    for ( keys %$parts ) {
        delete $qs{$_};
    }

    $spec{qs} = \%qs;

    # doc
    if ( $defn->{documentation}->{url} ) {
        $spec{doc} = $defn->{documentation}->{url} =~ m{/([^/]+)\.html$} ? $1 : '';
    }
    
    return \%spec;
}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



