Skip to content
This repository has been archived by the owner on Nov 8, 2020. It is now read-only.

Enable schema #133

Closed
wants to merge 3 commits into from
Closed
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
14 changes: 11 additions & 3 deletions CKAN-core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@
<Reference Include="log4net">
<HintPath>packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>packages\Newtonsoft.Json.6.0.5\lib\net40\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net40\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json.Schema, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.Schema.1.0.8\lib\net40\Newtonsoft.Json.Schema.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="nunit.framework">
<HintPath>packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
Expand Down Expand Up @@ -79,8 +84,11 @@
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<EmbeddedResource Include="CKAN.schema">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<ItemGroup />
</Project>
</Project>
310 changes: 310 additions & 0 deletions CKAN.schema
Original file line number Diff line number Diff line change
@@ -0,0 +1,310 @@
{
"$schema" : "http://json-schema.org/draft-04/schema#",
"title" : "CKAN JSON Schema",
"description" : "Schema for validating CKAN meta files",
"type" : "object",
"properties": {
"spec_version": {
"description" : "Version of the CKAN spec this document uses",
"oneOf" : [
{
"type" : "integer",
"description" : "The integer '1' is special cased",
"minimum" : 1,
"maximum" : 1
},
{
"type" : "string",
"description" : "A vx.x string",
"pattern" : "^v[0-9]+\\.[0-9]+$"
}
]
},
"name" : {
"description" : "Human readable name of the mod",
"type" : "string"
},
"identifier" : {
"description" : "Unique identifier for this mod.",
"$ref" : "#/definitions/identifier"
},
"kind" : {
"description" : "Package type, defaults to package.",
"enum" : [ "package", "metapackage" ]
},
"abstract" : {
"description" : "Short description of the mod",
"type" : "string"
},
"description" : {
"description" : "Longer description of the mod",
"type" : "string"
},
"comment" : {
"description" : "Free-form comment. Not displayed to users.",
"type" : "string"
},
"author" : {
"description" : "Author, or list of authors.",
"oneOf" : [
{ "type" : "string" },
{
"type" : "array",
"items" : { "type" : "string" },
"uniqueItems" : true
}
]
},
"download" : {
"description" : "URL where mod can be downloaded by tools",
"type" : "string",
"format" : "uri"
},
"download_size" : {
"description" : "The size of the download in bytes",
"type" : "integer"
},
"license" : {
"description" : "Machine readable license, or array of licenses",
"$ref" : "#/definitions/licenses"
},
"version" : {
"description" : "Version of the mod. Drop the leading v",
"$ref" : "#/definitions/version"
},
"release_status" : {
"description" : "Optional release status",
"enum" : [ "stable", "testing", "development" ]
},
"ksp_version" : {
"description" : "Optional target KSP version",
"$ref" : "#/definitions/ksp_version"
},
"ksp_version_min" : {
"description" : "Optional minimum KSP version",
"$ref" : "#/definitions/ksp_version"
},
"ksp_version_max" : {
"description" : "Optional maximum KSP version",
"$ref" : "#/definitions/ksp_version"
},
"depends" : {
"description" : "Optional list of dependencies",
"$ref" : "#/definitions/relationship"
},
"recommends" : {
"description" : "Optional list of recommended mods",
"$ref" : "#/definitions/relationship"
},
"suggests" : {
"description" : "Optional list of recommended, but not essential mods",
"$ref" : "#/definitions/relationship"
},
"supports" : {
"description" : "Optional list of supported mods",
"$ref" : "#/definitions/relationship"
},
"conflicts" : {
"description" : "Optional list of conflicting mods",
"$ref" : "#/definitions/relationship"
},
"provides" : {
"description" : "A list of virtual packages this mod provides",
"type" : "array",
"items" : { "type" : "string" },
"uniqueItems" : true
},
"resources" : {
"description" : "Additional resources",
"type" : "object",
"properties" : {
"homepage" : {
"description" : "Mod homepage",
"type" : "string",
"format" : "uri"
},
"bugtracker" : {
"description" : "Mod bugtracker",
"type" : "string",
"format" : "uri"
},
"license" : {
"description" : "Mod license",
"type" : "string",
"format" : "uri"
},
"repository" : {
"description" : "Mod repository",
"type" : "string",
"format" : "uri"
},
"ci" : {
"description" : "Continuous Integration",
"type" : "string",
"format" : "uri"
},
"kerbalstuff" : {
"description" : "Project on KerbalStuff",
"type" : "string",
"format" : "uri"
},
"manual" : {
"description" : "Mod's manual",
"type" : "string",
"format" : "uri"
}
}
},
"install" : {
"description" : "List of install directives",
"type" : "array",
"items" : {
"type" : "object",
"properties" : {
"file" : {
"description" : "Path to file to install",
"type" : "string"
},
"find" : {
"description" : "A directory to find for installation",
"type" : "string"
},
"install_to" : {
"description" : "Where file should be installed to",
"$ref" : "#/definitions/install_to"
},
"filter" : {
"description" : "List of files and directories that should be filtered from the install",
"$ref" : "#/definitions/one_or_more_strings"
},
"filter_regexp" : {
"description" : "List of regexps that should filter files from this install",
"$ref" : "#/definitions/one_or_more_strings"
}
},
"required" : [ "install_to" ],
"comment" : "One must have either file or find, is there a JSON Schema friendly way of specifying that?"
}
}
},
"required" : [
"spec_version",
"name",
"abstract",
"identifier",
"download",
"license",
"version"
],
"definitions" : {
"identifier" : {
"description" : "Unique identifier for this mod.",
"type" : "string",
"pattern" : "^[A-Za-z][A-Za-z0-9-]*$"
},
"version" : {
"description" : "A verison string",
"type" : "string"
},
"ksp_version" : {
"description" : "A version of KSP",
"type" : "string",
"pattern" : "^(any|[0-9]+\\.[0-9]+(\\.[0-9]+)?)$"
},
"relationship" : {
"description" : "A relationship to a list of mods",
"type" : "array",
"items" : {
"type" : "object",
"properties" : {
"name" : {
"description" : "Identifier of the mod",
"$ref" : "#/definitions/identifier"
},
"version" : {
"description" : "Optional version",
"$ref" : "#/definitions/version"
},
"min_version" : {
"description" : "Optional minimum version",
"$ref" : "#/definitions/version"
},
"max_version" : {
"description" : "Optional maximum version",
"$ref" : "#/definitions/version"
}
},
"required" : [ "name" ]
}
},
"install_to" : {
"description" : "Where file should be installed to. As of v1.2, GameData may take a path",
"oneOf" : [
{
"description" : "Spec version 1 targets",
"enum" : [ "GameData", "Ships", "GameRoot", "Tutorial" ]
},
{
"description" : "Spec v1.2 GameData path",
"type" : "string",
"pattern" : "^GameData/"
}
]
},
"license" : {
"description" : "A license.",
"enum" : [
"public-domain",
"Apache", "Apache-1.0", "Apache-2.0",
"Artistic", "Artistic-1.0", "Artistic-2.0",
"BSD-2-clause", "BSD-3-clause", "BSD-4-clause",
"ISC",
"CC-BY", "CC-BY-1.0", "CC-BY-2.0", "CC-BY-2.5", "CC-BY-3.0", "CC-BY-4.0",
"CC-BY-SA", "CC-BY-SA-1.0", "CC-BY-SA-2.0", "CC-BY-SA-2.5", "CC-BY-SA-3.0", "CC-BY-SA-4.0",
"CC-BY-NC", "CC-BY-NC-1.0", "CC-BY-NC-2.0", "CC-BY-NC-2.5", "CC-BY-NC-3.0", "CC-BY-NC-4.0",
"CC-BY-NC-SA", "CC-BY-NC-SA-1.0", "CC-BY-NC-SA-2.0", "CC-BY-NC-SA-2.5", "CC-BY-NC-SA-3.0", "CC-BY-NC-SA-4.0",
"CC-BY-NC-ND", "CC-BY-NC-ND-1.0", "CC-BY-NC-ND-2.0", "CC-BY-NC-ND-2.5", "CC-BY-NC-ND-3.0", "CC-BY-NC-ND-4.0",
"CC0",
"CDDL", "CPL",
"EFL-1.0", "EFL-2.0",
"Expat", "MIT",
"GPL-1.0", "GPL-2.0", "GPL-3.0",
"LGPL-2.0", "LGPL-2.1", "LGPL-3.0",
"GFDL-1.0", "GFDL-1.1", "GFDL-1.2", "GFDL-1.3",
"GFDL-NIV-1.0", "GFDL-NIV-1.1", "GFDL-NIV-1.2", "GFDL-NIV-1.3",
"LPPL-1.0", "LPPL-1.1", "LPPL-1.2", "LPPL-1.3c",
"MPL-1.1",
"Perl",
"Python-2.0",
"QPL-1.0",
"W3C",
"Zlib",
"Zope",
"WTFPL",
"open-source", "restricted", "unrestricted", "unknown"
]
},
"licenses" : {
"description" : "A license, or array of licenses",
"anyOf" : [
{ "$ref" : "#/definitions/license" },
{
"type" : "array",
"items" : { "$ref" : "#/definitions/license" },
"uniqueItems" : true
}
]
},
"one_or_more_strings" : {
"description" : "One or more strings",
"oneOf" : [
{ "type" : "string" },
{
"type" : "array",
"items" : { "type" : "string" },
"uniqueItems" : true
}
]
}
}
}
Binary file modified Tests/DATA/CKAN-meta-testkan.tar.gz
Binary file not shown.
Binary file modified Tests/DATA/CKAN-meta-testkan.zip
Binary file not shown.
8 changes: 2 additions & 6 deletions Tests/TestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ public static string DogeCoinFlag_101_bugged()
}
],
""resources"": {
""kerbalstuff"": {
""url"": ""https://kerbalstuff.com/mod/269/Dogecoin%20Flag""
},
""kerbalstuff"": ""https://kerbalstuff.com/mod/269/Dogecoin%20Flag"",
""homepage"": ""https://www.reddit.com/r/dogecoin/comments/1tdlgg/i_made_a_more_accurate_dogecoin_and_a_ksp_flag/""
},
""name"": ""Dogecoin Flag"",
Expand Down Expand Up @@ -112,9 +110,7 @@ public static string DogeCoinFlag_101()
}
],
""resources"": {
""kerbalstuff"": {
""url"": ""https://kerbalstuff.com/mod/269/Dogecoin%20Flag""
},
""kerbalstuff"": ""https://kerbalstuff.com/mod/269/Dogecoin%20Flag"",
""homepage"": ""https://www.reddit.com/r/dogecoin/comments/1tdlgg/i_made_a_more_accurate_dogecoin_and_a_ksp_flag/""
},
""name"": ""Dogecoin Flag"",
Expand Down
Loading