API-Docker
view release on metacpan or search on metacpan
lib/API/Docker/Type.pm view on Meta::CPAN
use API::Docker::Type;
docker_extends 'Resources';
C<allOf> in swagger means composition, and Perl inheritance says exactly
that. Nothing is duplicated: the parent's fields, their POD and the inline
classes declared inside the parent all stay in one place, and the merged
registry in L<API::Docker::Role::Type> presents C<HostConfig> with all ~70
fields. The alternative -- copying the parent's declarations into the child
-- would duplicate 31 attributes and their C<=attr> blocks and force the
inline classes underneath them to be named twice.
An C<allOf> holding a single C<$ref> and nothing else is not composition at
all; it is swagger's way of hanging a description on a C<$ref>
(C<Mount.Type> and C<MountPoint.Type> both do it). Such a field takes the
type of what it references, which for C<MountType> is C<Str>.
=head2 Inline objects become classes
A property whose schema is an object with its own C<properties>, or an array
whose C<items> are such an object, becomes a class named after the
definition that declares it:
Mount.BindOptions -> API::Docker::Type::Mount::BindOptions
Mount.VolumeOptions.DriverConfig
-> API::Docker::Type::Mount::VolumeOptions::DriverConfig
Resources.Ulimits[] -> API::Docker::Type::Resources::Ulimit
The last one is the exception to the mechanical rule: an array of inline
objects is named for one element, and turning C<Ulimits> into C<Ulimit> is a
judgement call, not a derivation. Those names live in
C<maint/spec-drift-exceptions.yaml> so the checker and a generator agree on
them.
=head2 A generated class loads what it references
Each class carries a plain C<use> for every other type class it names, so
loading C<API::Docker::Type::HostConfig> brings its whole subtree with it.
The declaration itself does B<not> load anything: a class named in a
C<docker> line is loaded lazily, on the first hashref that has to be
inflated into it. That is deliberate belt and braces -- v1.51's definitions
happen to have no reference cycles, and if a later version grows one the
C<use> for the back edge is what a generator has to leave out, while the
model keeps working either way.
=head1 THE TYPE VOCABULARY
Str Int Num Bool scalars
Any untyped; passed through as it arrived
[Str] an array of scalars
[[Str]] an array of arrays of scalars
['PortBinding'] an array of typed objects
'PortBinding' a single typed object
'+Some::Other::Class' the same, without the namespace prefix
{ Str, Str } a hash whose KEYS ARE CALLER DATA
{ Str, ['PortBinding'] } the same, with typed values
A bare class name is short: C<'PortBinding'> is
C<API::Docker::Type::PortBinding>, C<'Mount::BindOptions'> is
C<API::Docker::Type::Mount::BindOptions>. The expansion happens in
C<_expand_class> and nowhere else; a leading C<+> escapes it.
=head2 describe_type
API::Docker::Type::describe_type($info->{type}); # 'hash<array<object>>'
A descriptor as one string, for the drift checker's report. Objects render
as C<< object<Class> >>.
=head1 SUPPORT
=head2 Issues
Please report bugs and feature requests on GitHub at
L<https://github.com/Getty/p5-api-docker/issues>.
=head1 CONTRIBUTING
Contributions are welcome! Please fork the repository and submit a pull request.
=head1 AUTHOR
Torsten Raudssus <getty@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> L<https://raudssus.de/>.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
( run in 1.749 second using v1.01-cache-2.11-cpan-54e63673c56 )