From 9ce21d3b95ca2ca894bcd96d8f4731951fee0ef1 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Sun, 31 Dec 2023 14:43:35 -0300 Subject: [PATCH] fix: invalid jsonschema closes https://github.com/goreleaser/goreleaser/issues/4511 Signed-off-by: Carlos Alexandro Becker --- .github/workflows/generate.yml | 2 ++ Taskfile.yml | 7 +++++++ pkg/config/config.go | 12 ++++++------ www/docs/static/schema.json | 6 +++--- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 33bd340fb82..7fe975d561b 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -24,12 +24,14 @@ jobs: version: 3.x repo-token: ${{ secrets.GITHUB_TOKEN }} - run: "go install mvdan.cc/gofumpt@latest" + - run: "go install github.com/santhosh-tekuri/jsonschema/cmd/jv@latest" - run: task docs:releases env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: task docs:generate - run: task schema:generate - run: task nix:licenses:generate + - run: task schema:validate - uses: stefanzweifel/git-auto-commit-action@8756aa072ef5b4a080af5dc8fef36c5d586e521d # v5 with: commit_message: "chore: docs auto-update" diff --git a/Taskfile.yml b/Taskfile.yml index 77cc3714a91..6144193428e 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -80,6 +80,13 @@ tasks: generates: - ./www/docs/static/schema.json + schema:validate: + desc: Validate JSONSchema + cmds: + - jv ./www/docs/static/schema.json + sources: + - ./www/docs/static/schema.json + docs:generate: desc: Generate docs cmds: diff --git a/pkg/config/config.go b/pkg/config/config.go index a34ca28794d..ae230c0d389 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -285,8 +285,8 @@ func (a NixDependency) JSONSchema() *jsonschema.Schema { reflector := jsonschema.Reflector{ ExpandedStruct: true, } - type t NixDependency - schema := reflector.Reflect(&t{}) + type nixDependencyAlias NixDependency + schema := reflector.Reflect(&nixDependencyAlias{}) return &jsonschema.Schema{ OneOf: []*jsonschema.Schema{ { @@ -611,11 +611,11 @@ func (bh *Hook) UnmarshalYAML(unmarshal func(interface{}) error) error { } func (bh Hook) JSONSchema() *jsonschema.Schema { - type t Hook + type hookAlias Hook reflector := jsonschema.Reflector{ ExpandedStruct: true, } - schema := reflector.Reflect(&t{}) + schema := reflector.Reflect(&hookAlias{}) return &jsonschema.Schema{ OneOf: []*jsonschema.Schema{ { @@ -668,11 +668,11 @@ func (f *File) UnmarshalYAML(unmarshal func(interface{}) error) error { } func (f File) JSONSchema() *jsonschema.Schema { - type t File + type fileAlias File reflector := jsonschema.Reflector{ ExpandedStruct: true, } - schema := reflector.Reflect(&t{}) + schema := reflector.Reflect(&fileAlias{}) return &jsonschema.Schema{ OneOf: []*jsonschema.Schema{ { diff --git a/www/docs/static/schema.json b/www/docs/static/schema.json index 87f5131b40d..82b6ae998d1 100644 --- a/www/docs/static/schema.json +++ b/www/docs/static/schema.json @@ -913,7 +913,7 @@ }, { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://github.com/goreleaser/goreleaser/pkg/config/t", + "$id": "https://github.com/goreleaser/goreleaser/pkg/config/file-alias", "$defs": { "FileInfo": { "properties": { @@ -1300,7 +1300,7 @@ }, { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://github.com/goreleaser/goreleaser/pkg/config/t", + "$id": "https://github.com/goreleaser/goreleaser/pkg/config/hook-alias", "properties": { "dir": { "type": "string" @@ -2089,7 +2089,7 @@ }, { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://github.com/goreleaser/goreleaser/pkg/config/t", + "$id": "https://github.com/goreleaser/goreleaser/pkg/config/nix-dependency-alias", "properties": { "name": { "type": "string"