logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Rinci::Upgrading - Upgrading from previous version of specification

Author

       perlancar <perlancar@cpan.org>

Bugs

       Please report any bugs or feature requests on the bugtracker website
       <https://rt.cpan.org/Public/Dist/Display.html?Name=Rinci>

       When submitting a bug or request, please include a test-file or a patch to an existing test-file that
       illustrates the bug or desired feature.

perl v5.38.2                                       2024-01-20                              Rinci::Upgrading(3pm)

Contributing

       To contribute, you can send patches by email/via RT, or send pull requests on GitHub.

       Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then
       test via:

        % prove -l

       If you want to build the distribution (e.g. to try to install it locally on your system), you can install
       Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR,
       and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required
       beyond that are considered a bug and can be reported to me.

Description

       This document gives guide on how to convert your metadata from older version.

       Examples are written in Perl, but are not limited to this language.

Homepage

       Please visit the project's homepage at <https://metacpan.org/release/Rinci>.

Name

       Rinci::Upgrading - Upgrading from previous version of specification

Source

       Source repository is at <https://github.com/perlancar/perl-Rinci>.

Upgrading From Sub::Spec 1.0 To Rinci 1.1

Upgradingfunctionmetadata
       In Perl, you can use Perinci::Sub::Wrapper (which in turn is used by Perinci::Access) to automatically
       convert Sub::Spec 1.0 metadata to 1.1, so you can skip this document if you want.

       Terminology change: (sub)spec is now called metadata: the reason is because there are now metadata for
       functions as well as other code entities like variables, packages, etc. clause is now called property:
       the reason is to avoid confusion with Data::Sah's clause.

       The "v" (spec version) property is required, add

        v => 1.1

       to your function metadata.

       Each argument in the "args" property is now a hash, instead of a schema. Move the schema to the "schema"
       key of the hash. To specify required argument, add "req" set to 1 to hash key. Move "arg_pos" Sah clause
       to "pos" hash key. Move "arg_greedy" Sah clause to "greedy" hash key. Move "arg_completion" Sah clause to
       "completion" hash key.

       Example, change this:

        args => {
            # a required argument
            arg1 => ['int*', {
                summary => 'Blah ...',
                min => 1, max => 100,
                arg_pos => 0,
            }],

            # an optional argument
            arg2 => ['bool', {
                summary => 'Blah ...',
                default => 0,
            }],
        }

       Into this:

        args => {
            arg1 => {
                summary => 'Blah ...',
                schema => ['int*', {min=>1, max=>100}],
                req => 1,
                pos => 0,
            },

            arg2 => {
                summary => 'Blah ...',
                schema => [bool => {default=>0}],
            },
        }

       It is now possible to give summary and description to the schema as well as to the argument.

       Accordingly, the "result" property is also now a hash, instead of schema. Move the schema into the
       "schema" hash key.

   Sub::Spec::HTTP
       For the most part, you only need to upgrade client and server library. Client library is now
       Perinci::CmdLine and Perinci::Access. Server library is now "Perinci::Access::HTTP::Server".

       Specification is now Riap and Riap::HTTP. Terminology changes. SSrequest now becomes Riaprequest. Some
       key names changed (shortened).  Special headers are now prefixed with X-Riap-* instead of X-SS-Req-*.

       Log levels are now numeric only (1-6) instead of numeric/string.

Version

       This document describes version 1.1.104 of Rinci::Upgrading (from Perl distribution Rinci), released on
       2023-09-30.

See Also