diff --git a/lib/App/Changelord/Command/Validate.pm b/lib/App/Changelord/Command/Validate.pm index f86181c..9701fac 100644 --- a/lib/App/Changelord/Command/Validate.pm +++ b/lib/App/Changelord/Command/Validate.pm @@ -3,13 +3,19 @@ package App::Changelord::Command::Validate; use 5.36.0; use Moo; -use CLI::Osprey; +use CLI::Osprey + doc => 'validate the changelog yaml', + description_pod => <<'END'; +Validate the changelog against the JSON Schema used by changelord. +END use Path::Tiny; use JSON; use YAML::XS; use JSON::Schema::Modern; +with 'App::Changelord::Role::Changelog'; + option json => ( is => 'ro', default => 0, @@ -24,7 +30,7 @@ sub run($self) { my $result = JSON::Schema::Modern->new( output_format => 'detailed', )->evaluate( - $self->parent_command->changelog, + $self->changelog, YAML::XS::Load($schema), ); diff --git a/lib/App/Changelord/Command/changelog-schema.yml b/lib/App/Changelord/Command/changelog-schema.yml index 0f6aced..409587d 100644 --- a/lib/App/Changelord/Command/changelog-schema.yml +++ b/lib/App/Changelord/Command/changelog-schema.yml @@ -42,16 +42,18 @@ properties: - type: object additionalProperties: false properties: - version: { type: string } + version: { type: [ 'null', string ] } date: { type: ['null',string] } changes: { type: 'array', items: { $ref: '#/$defs/change' } } $defs: change: - type: object - required: [ desc ] - additionalProperties: false - properties: - desc: { type: string } - ticket: { type: [ string, 'null' ] } - type: { type: [ string, 'null' ] } - commit: { type: [ string, 'null' ] } + oneOf: + - type: string + - type: object + required: [ desc ] + additionalProperties: false + properties: + desc: { type: string } + ticket: { type: [ string, 'null' ] } + type: { type: [ string, 'null' ] } + commit: { type: [ string, 'null' ] }