Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,21 @@ jobs:
contents: write

steps:
- name: checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: get release
id: get_release
- id: get_release
uses: joutvhu/get-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: build
run: docker compose run --env RELEASE=${{ steps.get_release.outputs.tag_name }} spec
- run: docker compose run --env RELEASE=${{ steps.get_release.outputs.tag_name }} spec

- name: release
uses: softprops/action-gh-release@v2
- uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/v')
with:
files: |
tmp/rst-api-spec.yaml
tmp/rst-api-spec.json
tmp/rst-api-spec-unannotated.json
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ spec: tmpdir includes
@echo Generating JSON file...
@yq -o=json eval tmp/rst-api-spec.yaml > tmp/rst-api-spec.json

@echo Generating unannotated JSON file...
@bin/unannotate.pl tmp/rst-api-spec.json > tmp/rst-api-spec-unannotated.json

static-html:
@echo Generating static HTML file...
@openapi-generator generate -g html -i tmp/rst-api-spec.yaml >/dev/null
Expand Down
33 changes: 33 additions & 0 deletions bin/unannotate.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env perl
use File::Slurp;
use JSON::XS;
use constant ANNOTATION_KEY => q{x-field-extra-annotation};
use vars qw($JSON $VALUE);
use common::sense;

$JSON = JSON::XS->new->utf8->canonical->pretty;

$VALUE = $JSON->decode(join('', read_file($ARGV[0])));

unannotate($VALUE);

print $JSON->encode($VALUE);

sub unannotate {
my $value = shift;

if (q{HASH} eq ref($value)) {
foreach my $key (keys(%{$value})) {
if (lc($key) eq ANNOTATION_KEY) {
delete($value->{$key});
} else {
unannotate($value->{$key});
}
}

} elsif (q{ARRAY} eq ref($value)) {
for (my $i = 0 ; $i < scalar(@{$value}) ; $i++) {
unannotate($value->[$i]);
}
}
}