From 6fb6e27db0b9bd7dcf252239b2264e3b3229a71d Mon Sep 17 00:00:00 2001 From: Fabio Bonelli Date: Wed, 15 Oct 2025 08:55:43 +0200 Subject: [PATCH] feat: add organisation See https://github.com/publiccodeyml/publiccode.yml/pull/229 --- parser_test.go | 18 ++++++ .../v0/invalid/organisation_name_missing.yml | 55 ++++++++++++++++++ .../organisation_uri_wrong_italian_pa.yml | 56 +++++++++++++++++++ .../organisation_uri_wrong_italian_pa2.yml | 55 ++++++++++++++++++ .../v0/invalid/organisation_wrong_type.yml | 55 ++++++++++++++++++ .../v0/invalid/organisation_wrong_uri.yml | 55 ++++++++++++++++++ testdata/v0/valid/valid_with_organisation.yml | 53 ++++++++++++++++++ ...valid_with_organisation_uri_italian_pa.yml | 54 ++++++++++++++++++ .../valid_with_organisation_with_uri_url.yml | 54 ++++++++++++++++++ .../valid_with_organisation_with_uri_urn.yml | 54 ++++++++++++++++++ v0.go | 5 ++ 11 files changed, 514 insertions(+) create mode 100644 testdata/v0/invalid/organisation_name_missing.yml create mode 100644 testdata/v0/invalid/organisation_uri_wrong_italian_pa.yml create mode 100644 testdata/v0/invalid/organisation_uri_wrong_italian_pa2.yml create mode 100644 testdata/v0/invalid/organisation_wrong_type.yml create mode 100644 testdata/v0/invalid/organisation_wrong_uri.yml create mode 100644 testdata/v0/valid/valid_with_organisation.yml create mode 100644 testdata/v0/valid/valid_with_organisation_uri_italian_pa.yml create mode 100644 testdata/v0/valid/valid_with_organisation_with_uri_url.yml create mode 100644 testdata/v0/valid/valid_with_organisation_with_uri_urn.yml diff --git a/parser_test.go b/parser_test.go index 66512fd0..7a66f582 100644 --- a/parser_test.go +++ b/parser_test.go @@ -300,6 +300,24 @@ func TestInvalidTestcasesV0(t *testing.T) { ValidationError{"monochromeLogo", "no such file: " + cwd + "/testdata/v0/invalid/no_such_file.png", 18, 1}, }, + // organisation + "organisation_wrong_uri.yml": ValidationResults{ + ValidationError{"organisation.uri", "uri is not a valid URI", 19, 3}, + }, + "organisation_wrong_type.yml": ValidationResults{ + ValidationError{"organisation.name", "wrong type for this field", 18, 1}, + ValidationError{"organisation.name", "name is a required field", 18, 3}, + }, + "organisation_name_missing.yml": ValidationResults{ + ValidationError{"organisation.name", "name is a required field", 17, 3}, + }, + "organisation_uri_wrong_italian_pa.yml": ValidationResults{ + ValidationError{"organisation.uri", "uri is not a valid URI", 20, 3}, + }, + "organisation_uri_wrong_italian_pa2.yml": ValidationResults{ + ValidationError{"organisation.uri", "uri must be a valid Italian Public Administration Code (iPA) with format 'urn:x-italian-pa:[codiceIPA]' (see https://www.indicepa.gov.it/public-services/opendata-read-service.php?dstype=FS&filename=amministrazioni.txt)", 19, 3}, + }, + // inputTypes "inputTypes_invalid.yml": ValidationResults{ ValidationError{"inputTypes[1]", "inputTypes[1] is not a valid MIME type", 1, 1}, diff --git a/testdata/v0/invalid/organisation_name_missing.yml b/testdata/v0/invalid/organisation_name_missing.yml new file mode 100644 index 00000000..8a23489f --- /dev/null +++ b/testdata/v0/invalid/organisation_name_missing.yml @@ -0,0 +1,55 @@ +publiccodeYmlVersion: "0.4" + +name: Medusa +url: "https://github.com/italia/developers.italia.it.git" + +platforms: + - web + +categories: + - cloud-management + +developmentStatus: development + +softwareType: "standalone/other" + +organisation: + uri: "https://example.org" + # Should NOT validate: name is missing + # name: foobar + +description: + en-GB: + localisedName: Medusa + shortDescription: > + A rather short description which + is probably useless + longDescription: > + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 158 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 316 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 474 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 632 characters. + features: + - Just one feature + +legal: + license: AGPL-3.0-or-later + +maintenance: + type: "community" + + contacts: + - name: Francesco Rossi + +localisation: + localisationReady: true + availableLanguages: + - en diff --git a/testdata/v0/invalid/organisation_uri_wrong_italian_pa.yml b/testdata/v0/invalid/organisation_uri_wrong_italian_pa.yml new file mode 100644 index 00000000..fe330e33 --- /dev/null +++ b/testdata/v0/invalid/organisation_uri_wrong_italian_pa.yml @@ -0,0 +1,56 @@ +publiccodeYmlVersion: "0.4" + +name: Medusa +url: "https://github.com/italia/developers.italia.it.git" + +platforms: + - web + +categories: + - cloud-management + +developmentStatus: development + +softwareType: "standalone/other" + +organisation: + name: foobar + # Should NOT validate: uri is a literal Italian CodiceIPA, + # but should be in the format urn:x-italian-pa:[codiceIPA] + uri: pcm + +description: + en-GB: + localisedName: Medusa + shortDescription: > + A rather short description which + is probably useless + longDescription: > + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 158 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 316 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 474 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 632 characters. + features: + - Just one feature + +legal: + license: AGPL-3.0-or-later + +maintenance: + type: "community" + + contacts: + - name: Francesco Rossi + +localisation: + localisationReady: true + availableLanguages: + - en diff --git a/testdata/v0/invalid/organisation_uri_wrong_italian_pa2.yml b/testdata/v0/invalid/organisation_uri_wrong_italian_pa2.yml new file mode 100644 index 00000000..2f449fef --- /dev/null +++ b/testdata/v0/invalid/organisation_uri_wrong_italian_pa2.yml @@ -0,0 +1,55 @@ +publiccodeYmlVersion: "0.4" + +name: Medusa +url: "https://github.com/italia/developers.italia.it.git" + +platforms: + - web + +categories: + - cloud-management + +developmentStatus: development + +softwareType: "standalone/other" + +organisation: + name: foobar + # Should NOT validate: invalid Italian PA, + uri: urn:x-italian-pa:no_such_pa + +description: + en-GB: + localisedName: Medusa + shortDescription: > + A rather short description which + is probably useless + longDescription: > + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 158 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 316 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 474 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 632 characters. + features: + - Just one feature + +legal: + license: AGPL-3.0-or-later + +maintenance: + type: "community" + + contacts: + - name: Francesco Rossi + +localisation: + localisationReady: true + availableLanguages: + - en diff --git a/testdata/v0/invalid/organisation_wrong_type.yml b/testdata/v0/invalid/organisation_wrong_type.yml new file mode 100644 index 00000000..210a78e5 --- /dev/null +++ b/testdata/v0/invalid/organisation_wrong_type.yml @@ -0,0 +1,55 @@ +publiccodeYmlVersion: "0.4" + +name: Medusa +url: "https://github.com/italia/developers.italia.it.git" + +platforms: + - web + +categories: + - cloud-management + +developmentStatus: development + +softwareType: "standalone/other" + +organisation: + # Should NOT validate: organisation has to be an object, not a list + - name: foobar + uri: "urn:foo:bar" + +description: + en-GB: + localisedName: Medusa + shortDescription: > + A rather short description which + is probably useless + longDescription: > + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 158 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 316 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 474 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 632 characters. + features: + - Just one feature + +legal: + license: AGPL-3.0-or-later + +maintenance: + type: "community" + + contacts: + - name: Francesco Rossi + +localisation: + localisationReady: true + availableLanguages: + - en diff --git a/testdata/v0/invalid/organisation_wrong_uri.yml b/testdata/v0/invalid/organisation_wrong_uri.yml new file mode 100644 index 00000000..d01aa10d --- /dev/null +++ b/testdata/v0/invalid/organisation_wrong_uri.yml @@ -0,0 +1,55 @@ +publiccodeYmlVersion: "0.4" + +name: Medusa +url: "https://github.com/italia/developers.italia.it.git" + +platforms: + - web + +categories: + - cloud-management + +developmentStatus: development + +softwareType: "standalone/other" + +organisation: + name: foobar + # Should NOT validate: uri is an invalid URI + uri: "1" + +description: + en-GB: + localisedName: Medusa + shortDescription: > + A rather short description which + is probably useless + longDescription: > + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 158 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 316 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 474 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 632 characters. + features: + - Just one feature + +legal: + license: AGPL-3.0-or-later + +maintenance: + type: "community" + + contacts: + - name: Francesco Rossi + +localisation: + localisationReady: true + availableLanguages: + - en diff --git a/testdata/v0/valid/valid_with_organisation.yml b/testdata/v0/valid/valid_with_organisation.yml new file mode 100644 index 00000000..d72e896b --- /dev/null +++ b/testdata/v0/valid/valid_with_organisation.yml @@ -0,0 +1,53 @@ +publiccodeYmlVersion: "0.4" + +name: Medusa +url: "https://github.com/italia/developers.italia.it.git" + +platforms: + - web + +categories: + - cloud-management + +developmentStatus: development + +softwareType: "standalone/other" + +organisation: + name: foobar + +description: + en-GB: + localisedName: Medusa + shortDescription: > + A rather short description which + is probably useless + longDescription: > + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 158 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 316 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 474 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 632 characters. + features: + - Just one feature + +legal: + license: AGPL-3.0-or-later + +maintenance: + type: "community" + + contacts: + - name: Francesco Rossi + +localisation: + localisationReady: true + availableLanguages: + - en diff --git a/testdata/v0/valid/valid_with_organisation_uri_italian_pa.yml b/testdata/v0/valid/valid_with_organisation_uri_italian_pa.yml new file mode 100644 index 00000000..b054b073 --- /dev/null +++ b/testdata/v0/valid/valid_with_organisation_uri_italian_pa.yml @@ -0,0 +1,54 @@ +publiccodeYmlVersion: "0.4" + +name: Medusa +url: "https://github.com/italia/developers.italia.it.git" + +platforms: + - web + +categories: + - cloud-management + +developmentStatus: development + +softwareType: "standalone/other" + +organisation: + name: foobar + uri: urn:x-italian-pa:pcm + +description: + en-GB: + localisedName: Medusa + shortDescription: > + A rather short description which + is probably useless + longDescription: > + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 158 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 316 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 474 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 632 characters. + features: + - Just one feature + +legal: + license: AGPL-3.0-or-later + +maintenance: + type: "community" + + contacts: + - name: Francesco Rossi + +localisation: + localisationReady: true + availableLanguages: + - en diff --git a/testdata/v0/valid/valid_with_organisation_with_uri_url.yml b/testdata/v0/valid/valid_with_organisation_with_uri_url.yml new file mode 100644 index 00000000..75ecf76d --- /dev/null +++ b/testdata/v0/valid/valid_with_organisation_with_uri_url.yml @@ -0,0 +1,54 @@ +publiccodeYmlVersion: "0.4" + +name: Medusa +url: "https://github.com/italia/developers.italia.it.git" + +platforms: + - web + +categories: + - cloud-management + +developmentStatus: development + +softwareType: "standalone/other" + +organisation: + name: foobar + uri: https://foobar.example/xyz + +description: + en-GB: + localisedName: Medusa + shortDescription: > + A rather short description which + is probably useless + longDescription: > + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 158 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 316 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 474 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 632 characters. + features: + - Just one feature + +legal: + license: AGPL-3.0-or-later + +maintenance: + type: "community" + + contacts: + - name: Francesco Rossi + +localisation: + localisationReady: true + availableLanguages: + - en diff --git a/testdata/v0/valid/valid_with_organisation_with_uri_urn.yml b/testdata/v0/valid/valid_with_organisation_with_uri_urn.yml new file mode 100644 index 00000000..18a5578e --- /dev/null +++ b/testdata/v0/valid/valid_with_organisation_with_uri_urn.yml @@ -0,0 +1,54 @@ +publiccodeYmlVersion: "0.4" + +name: Medusa +url: "https://github.com/italia/developers.italia.it.git" + +platforms: + - web + +categories: + - cloud-management + +developmentStatus: development + +softwareType: "standalone/other" + +organisation: + name: foobar + uri: urn:foobar:example + +description: + en-GB: + localisedName: Medusa + shortDescription: > + A rather short description which + is probably useless + longDescription: > + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 158 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 316 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 474 characters. + Very long description of this software, also split + on multiple rows. You should note what the software + is and why one should need it. This is 632 characters. + features: + - Just one feature + +legal: + license: AGPL-3.0-or-later + +maintenance: + type: "community" + + contacts: + - name: Francesco Rossi + +localisation: + localisationReady: true + availableLanguages: + - en diff --git a/v0.go b/v0.go index 0d5fff41..2628c44d 100644 --- a/v0.go +++ b/v0.go @@ -20,6 +20,11 @@ type PublicCodeV0 struct { Logo string `json:"logo,omitempty" yaml:"logo,omitempty"` MonochromeLogo string `json:"monochromeLogo,omitempty" yaml:"monochromeLogo,omitempty"` + Organisation *struct { + Name string `json:"name" validate:"required" yaml:"name"` + URI *string `json:"uri,omitempty" validate:"omitempty,organisation_uri" yaml:"uri,omitempty"` + } `json:"organisation,omitempty" yaml:"organisation,omitempty"` + InputTypes []string `json:"inputTypes,omitempty" validate:"omitempty,dive,is_mime_type" yaml:"inputTypes,omitempty"` OutputTypes []string `json:"outputTypes,omitempty" validate:"omitempty,dive,is_mime_type" yaml:"outputTypes,omitempty"`