License Perl CI MetaCPAN package CPAN version CPAN testers

NAME

Modern::OpenAPI::Generator - OpenAPI 3.x client/server generator for Mojolicious

SYNOPSIS

perl bin/oapi-perl-gen --name MyApp::API --output ./out openapi.yaml

# or from Perl:
use Modern::OpenAPI::Generator;
Modern::OpenAPI::Generator->new(
  spec_path  => 'openapi.yaml',
  output_dir => './generated',
  name       => 'MyApp::API',
)->run;

DESCRIPTION

Generates:

See Modern::OpenAPI::Generator::CLI (oapi-perl-gen --help) for --client / --server / --ui selection rules. For Swagger UI, the generated script/server.pl prepends the request origin to servers in the served YAML only when run with --local-test (runtime) or OAPI_SWAGGER_LOCAL_ORIGIN=1 — this is separate from oapi-perl-gen --local-test (codegen stubs).

METHODS

new

Builds a generator instance. Required: spec_path, output_dir, name. Optional boolean / list keys include client, server, ui, sync, async, skeleton, force, merge, signatures, local_test.

run

Loads the OpenAPI document, emits files under output_dir, writes a root cpanfile, and returns $self.

INSTALLATION

After installing the distribution from CPAN (cpanm Modern::OpenAPI::Generator) or from a source tree (perl Makefile.PL && make && make install), the oapi-perl-gen script is on your PATH.

DEVELOPMENT

When running tests from a checkout, remove any stale blib/ directory first so lib/ is used (see the project README.md / CONTRIBUTING.md).

SEE ALSO

OpenAPI::Modern, Mojolicious::Plugin::OpenAPI, Mojolicious::Plugin::SwaggerUI, YAML::PP, Moo.

COPYRIGHT AND LICENSE

Copyright (c) 2026 by the Modern::OpenAPI::Generator authors. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.