Skip to content

Commit a2c657a

Browse files
committed
Adds go mod, updates schema
1 parent e691c86 commit a2c657a

3 files changed

Lines changed: 78 additions & 127 deletions

File tree

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module github.com/spaceapi-community/go-spaceapi-validator
2+
3+
go 1.13
4+
5+
require github.com/xeipuuv/gojsonschema v1.2.0

go.sum

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
2+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
5+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
6+
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
7+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
8+
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c=
9+
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
10+
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
11+
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
12+
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
13+
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=

schemas.go

Lines changed: 60 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package spaceapiValidator
22

33
// CommitHash contains the hash of the commit the Validate function validates against
4-
var CommitHash = "85008147fdd12809bff3b23291d6b5ea5f6e8b9d"
4+
var CommitHash = "377001fa1abb25d8988f187e7ad4d40d900d81b8"
55

66
// SpaceApiSchemas load from the repository as a map
77
var SpaceApiSchemas = map[string]string{
88
"11": `{
9-
"$schema": "http://json-schema.org/draft-06/schema#",
9+
"$id": "https://schema.spaceapi.io/11.json",
10+
"$schema": "http://json-schema.org/draft-07/schema#",
1011
"description": "SpaceAPI 0.11",
1112
"type": "object",
1213
"properties": {
@@ -163,9 +164,11 @@ var SpaceApiSchemas = map[string]string{
163164
"open",
164165
"icon"
165166
]
166-
}`,
167+
}
168+
`,
167169
"12": `{
168-
"$schema": "http://json-schema.org/draft-06/schema#",
170+
"$id": "https://schema.spaceapi.io/12.json",
171+
"$schema": "http://json-schema.org/draft-07/schema#",
169172
"description": "SpaceAPI 0.12",
170173
"type": "object",
171174
"properties": {
@@ -360,9 +363,11 @@ var SpaceApiSchemas = map[string]string{
360363
"open",
361364
"icon"
362365
]
363-
}`,
366+
}
367+
`,
364368
"13": `{
365-
"$schema": "http://json-schema.org/draft-06/schema#",
369+
"$id": "https://schema.spaceapi.io/13.json",
370+
"$schema": "http://json-schema.org/draft-07/schema#",
366371
"description": "SpaceAPI 0.13",
367372
"type": "object",
368373
"properties": {
@@ -398,7 +403,7 @@ var SpaceApiSchemas = map[string]string{
398403
"type": "number"
399404
},
400405
"lon": {
401-
"description": "Longitude of your space location, in degree with decimal places. Use positive values for locations west of Greenwich, and negative values for locations east of Greenwich.",
406+
"description": "Longitude of your space location, in degree with decimal places. Use positive values for locations east of Greenwich, and negative values for locations west of Greenwich.",
402407
"type": "number"
403408
}
404409
},
@@ -439,11 +444,11 @@ var SpaceApiSchemas = map[string]string{
439444
"minItems": 1
440445
},
441446
"stream": {
442-
"description": "A mapping of stream types to stream URLs.If you use other stream types make a <a href=\"add-your-space\" target=\"_blank\">change request</a> or prefix yours with <samp>ext_</samp> .",
447+
"description": "A mapping of stream types to stream URLs. If you use other stream types make a <a href=\"https://github.com/spaceapi/schema/pulls\" target=\"_blank\">pull request</a> or prefix yours with <samp>ext_</samp>.",
443448
"type": "object",
444449
"properties": {
445450
"m4": {
446-
"description": "Your mpg stream URL. Example: <samp>{\"mp4\": \"http//example.org/stream.mpg\"}</samp>",
451+
"description": "Your mpg stream URL. Example: <samp>{\"mp4\": \"http://example.org/stream.mpg\"}</samp>",
447452
"type": "string"
448453
},
449454
"mjpeg": {
@@ -1118,7 +1123,7 @@ var SpaceApiSchemas = map[string]string{
11181123
]
11191124
},
11201125
"direction": {
1121-
"description": "The wind direction in degrees. Use this <a href=\"https://github.com/slopjong/OpenSpaceLint/issues/80\" target=\"_blank_\">mapping</a> to convert the degrees into a string.",
1126+
"description": "The wind direction in degrees.",
11221127
"type": "object",
11231128
"properties": {
11241129
"value": {
@@ -1254,7 +1259,7 @@ var SpaceApiSchemas = map[string]string{
12541259
"type": "number"
12551260
},
12561261
"unit": {
1257-
"description": "What's the currency? If your currency is missing open a new <a href=\"https://github.com/slopjong/OpenSpaceLint/issues\" target=\"_blank\">issue</a> and request the addition of your currency according <a href=\"http://de.wikipedia.org/wiki/ISO_4217\" target=\"_blank\">ISO 4217</a>.",
1262+
"description": "What's the currency? Please use the ones provided, in the next version you can use currency definitions according to <a href=\"https://en.wikipedia.org/wiki/ISO_4217\" target=\"_blank\">ISO 4217</a>",
12581263
"type": "string",
12591264
"enum": [
12601265
"BTC",
@@ -1506,9 +1511,11 @@ var SpaceApiSchemas = map[string]string{
15061511
"contact",
15071512
"issue_report_channels"
15081513
]
1509-
}`,
1514+
}
1515+
`,
15101516
"14": `{
1511-
"$schema": "http://json-schema.org/draft-06/schema#",
1517+
"$id": "https://schema.spaceapi.io/14-draft.json",
1518+
"$schema": "http://json-schema.org/draft-07/schema#",
15121519
"description": "SpaceAPI 0.14",
15131520
"type": "object",
15141521
"properties": {
@@ -1544,7 +1551,7 @@ var SpaceApiSchemas = map[string]string{
15441551
"type": "number"
15451552
},
15461553
"lon": {
1547-
"description": "Longitude of your space location, in degree with decimal places. Use positive values for locations west of Greenwich, and negative values for locations east of Greenwich.",
1554+
"description": "Longitude of your space location, in degree with decimal places. Use positive values for locations east of Greenwich, and negative values for locations west of Greenwich.",
15481555
"type": "number"
15491556
},
15501557
"timezone": {
@@ -1592,7 +1599,7 @@ var SpaceApiSchemas = map[string]string{
15921599
"description": "A mapping of stream types to stream URLs.If you use other stream types make a <a href=\"add-your-space\" target=\"_blank\">change request</a> or prefix yours with <samp>ext_</samp> .",
15931600
"type": "object",
15941601
"properties": {
1595-
"m4": {
1602+
"mp4": {
15961603
"description": "Your mpg stream URL. Example: <samp>{\"mp4\": \"http//example.org/stream.mpg\"}</samp>",
15971604
"type": "string"
15981605
},
@@ -1611,11 +1618,8 @@ var SpaceApiSchemas = map[string]string{
16111618
"type": "object",
16121619
"properties": {
16131620
"open": {
1614-
"description": "A flag which indicates if the space is currently open or closed. The state 'undefined' can be achieved by assigning this field the value 'null' (without the quotes). In most (all?) programming languages this is evaluated to false so that no app should break",
1615-
"type": [
1616-
"boolean",
1617-
"null"
1618-
]
1621+
"description": "A flag which indicates whether the space is currently open or closed. The state 'undefined' can be achieved by omitting this field. A missing 'open' property carries the semantics of a temporary unavailability of the state, whereas the absence of the 'state' property itself means the state is generally not implemented for this space.",
1622+
"type": "boolean"
16191623
},
16201624
"lastchange": {
16211625
"description": "The Unix timestamp when the space status changed most recently",
@@ -1647,10 +1651,7 @@ var SpaceApiSchemas = map[string]string{
16471651
"closed"
16481652
]
16491653
}
1650-
},
1651-
"required": [
1652-
"open"
1653-
]
1654+
}
16541655
},
16551656
"events": {
16561657
"description": "Events which happened recently in your space and which could be interesting to the public, like 'User X has entered/triggered/did something at timestamp Z'",
@@ -1724,6 +1725,14 @@ var SpaceApiSchemas = map[string]string{
17241725
"xmpp": {
17251726
"description": "XMPP (Jabber) ID",
17261727
"type": "string"
1728+
},
1729+
"mastodon": {
1730+
"description": "Mastodon username. Example: @ordnung@chaos.social",
1731+
"type": "string"
1732+
},
1733+
"matrix": {
1734+
"description": "Matrix username. Example: <samp>@user:example.org</samp>",
1735+
"type": "string"
17271736
}
17281737
}
17291738
}
@@ -1736,20 +1745,14 @@ var SpaceApiSchemas = map[string]string{
17361745
"description": "Twitter handle, with leading @",
17371746
"type": "string"
17381747
},
1748+
"mastodon": {
1749+
"description": "Mastodon username: Example: @ordnung@chaos.social.",
1750+
"type": "string"
1751+
},
17391752
"facebook": {
17401753
"description": "Facebook account URL.",
17411754
"type": "string"
17421755
},
1743-
"google": {
1744-
"description": "Google services.",
1745-
"type": "object",
1746-
"properties": {
1747-
"plus": {
1748-
"description": "Google plus URL.",
1749-
"type": "string"
1750-
}
1751-
}
1752-
},
17531756
"identica": {
17541757
"description": "Identi.ca or StatusNet account, in the form <samp>yourspace@example.org</samp>",
17551758
"type": "string"
@@ -1771,25 +1774,19 @@ var SpaceApiSchemas = map[string]string{
17711774
"type": "string"
17721775
},
17731776
"issue_mail": {
1774-
"description": "A separate email address for issue reports (see the <em>issue_report_channels</em> field). This value can be Base64-encoded.",
1777+
"description": "A separate email address for issue reports. This value can be Base64-encoded.",
1778+
"type": "string"
1779+
},
1780+
"gopher": {
1781+
"description": "A URL to find information about the Space in the Gopherspace. Example: gopher://gopher.binary-kitchen.de",
1782+
"type": "string"
1783+
},
1784+
"matrix": {
1785+
"description": "Matrix channel/community for the Hackerspace. Example: <samp>#spaceroom:example.org</samp> or <samp>+spacecommunity:example.org</samp>",
17751786
"type": "string"
17761787
}
17771788
}
17781789
},
1779-
"issue_report_channels": {
1780-
"description": "This array defines all communication channels where you want to get automated issue reports about your SpaceAPI endpoint from the revalidator. This field is meant for internal usage only and it should never be consumed by any app. At least one channel must be defined. Please consider that when using <samp>ml</samp> the mailing list moderator has to moderate incoming emails or add the sender email to the subscribers. If you don't break your SpaceAPI implementation you won't get any notifications ;-)",
1781-
"type": "array",
1782-
"items": {
1783-
"type": "string",
1784-
"enum": [
1785-
"email",
1786-
"issue_mail",
1787-
"twitter",
1788-
"ml"
1789-
]
1790-
},
1791-
"minItems": 1
1792-
},
17931790
"sensors": {
17941791
"description": "Data of various sensors in your space (e.g. temperature, humidity, amount of Club-Mate left, \u2026). The only canonical property is the <em>temp</em> property, additional sensor types may be defined by you. In this case, you are requested to share your definition for inclusion in this specification.",
17951792
"type": "object",
@@ -2272,7 +2269,7 @@ var SpaceApiSchemas = map[string]string{
22722269
]
22732270
},
22742271
"direction": {
2275-
"description": "The wind direction in degrees. Use this <a href=\"https://github.com/slopjong/OpenSpaceLint/issues/80\" target=\"_blank_\">mapping</a> to convert the degrees into a string.",
2272+
"description": "The wind direction in degrees.",
22762273
"type": "object",
22772274
"properties": {
22782275
"value": {
@@ -2570,81 +2567,15 @@ var SpaceApiSchemas = map[string]string{
25702567
}
25712568
}
25722569
},
2573-
"cache": {
2574-
"description": "Specifies options about caching of your SpaceAPI endpoint. Use this if you want to avoid hundreds/thousands of application instances crawling your status.",
2575-
"type": "object",
2576-
"properties": {
2577-
"schedule": {
2578-
"description": "Cache update cycle. This field must match the basic regular expression <code>^[mhd]\\.[0-9]{2}$</code>, where the first field specifies a unit of time (<code>m</code> for 1 minute, <code>h</code> for 1 hour, <code>d</code> for 1 day), and the second field specifies how many of this unit should be skipped between updates. For example, <samp>m.10</samp> means one updates every 10 minutes, <samp>h.03</samp> means one update every 3 hours, and <samp>d.01</samp> means one update every day.",
2579-
"type": "string",
2580-
"enum": [
2581-
"m.02",
2582-
"m.05",
2583-
"m.10",
2584-
"m.15",
2585-
"m.30",
2586-
"h.01",
2587-
"h.02",
2588-
"h.04",
2589-
"h.08",
2590-
"h.12",
2591-
"d.01"
2592-
]
2593-
}
2594-
},
2595-
"required": [
2596-
"schedule"
2597-
]
2598-
},
25992570
"projects": {
26002571
"description": "Your project sites (links to GitHub, wikis or wherever your projects are hosted)",
26012572
"type": "array",
26022573
"items": {
26032574
"type": "string"
26042575
}
26052576
},
2606-
"radio_show": {
2607-
"description": "A list of radio shows that your hackerspace might broadcast.",
2608-
"type": "array",
2609-
"items": {
2610-
"type": "object",
2611-
"properties": {
2612-
"name": {
2613-
"description": "The name of the radio show.",
2614-
"type": "string"
2615-
},
2616-
"url": {
2617-
"description": "The stream URL which must end in a filename or a semicolon such as <br><ul><li>http://signal.hackerspaces.org:8090/signal.mp3</li><li>http://85.214.64.213:8060/;</ul>",
2618-
"type": "string"
2619-
},
2620-
"type": {
2621-
"description": "The stream encoder.",
2622-
"type": "string",
2623-
"enum": [
2624-
"mp3",
2625-
"ogg"
2626-
]
2627-
},
2628-
"start": {
2629-
"description": "Specify the start time by using the <a href=\"http://en.wikipedia.org/wiki/ISO_8601\" target=\"_blank\">ISO 8601</a> standard. This encodes the time as follows: <br><br><ul><li>Combined date and time in UTC: 2013-06-10T10:00Z</li><li>Combined date and time in localtime with the timezone offset: 2013-06-10T12:00+02:00</li><li>Combined date and time in localtime with the timezone offset: 2013-06-10T07:00-03:00</li></ul> The examples refer all to the same time.",
2630-
"type": "string"
2631-
},
2632-
"end": {
2633-
"description": "Specify the end time by using the <a href=\"http://en.wikipedia.org/wiki/ISO_8601\" target=\"_blank\">ISO 8601</a> standard. This encodes the time as follows: <br><br><ul><li>Combined date and time in UTC: 2013-06-10T10:00Z</li><li>Combined date and time in localtime with the timezone offset: 2013-06-10T12:00+02:00</li><li>Combined date and time in localtime with the timezone offset: 2013-06-10T07:00-03:00</li></ul> The examples refer all to the same time.",
2634-
"type": "string"
2635-
}
2636-
},
2637-
"required": [
2638-
"name",
2639-
"url",
2640-
"type",
2641-
"start",
2642-
"end"
2643-
]
2644-
}
2645-
},
26462577
"membership_plans": {
2647-
"description": "A list of the different membership plans your hackerspace might have.",
2578+
"description": "A list of the different membership plans your hackerspace might have. Set the value according to your billing process. For example, if your membership fee is 10€ per month, but you bill it yearly (aka. the member pays the fee once per year), set the amount to 120 an the billing_interval to yearly.",
26482579
"type": "array",
26492580
"items": {
26502581
"type": "object",
@@ -2661,8 +2592,8 @@ var SpaceApiSchemas = map[string]string{
26612592
"description": "What's the currency? It should be formatted according to <a href=\"https://en.wikipedia.org/wiki/ISO_4217\" target=\"_blank\">ISO 4217</a> short-code format.",
26622593
"type": "string"
26632594
},
2664-
"renewal_interval": {
2665-
"description": "How often is the membership renewed? If you select other, please specify in the description what your renewal interval is.",
2595+
"billing_interval": {
2596+
"description": "How often is the membership billed? If you select other, please specify in the description what your billing interval is.",
26662597
"type": "string",
26672598
"enum": [
26682599
"yearly",
@@ -2682,7 +2613,7 @@ var SpaceApiSchemas = map[string]string{
26822613
"name",
26832614
"value",
26842615
"currency",
2685-
"renewal_interval"
2616+
"billing_interval"
26862617
]
26872618
}
26882619
}
@@ -2693,14 +2624,13 @@ var SpaceApiSchemas = map[string]string{
26932624
"logo",
26942625
"url",
26952626
"location",
2696-
"state",
2697-
"contact",
2698-
"issue_report_channels"
2627+
"contact"
26992628
]
27002629
}
27012630
`,
27022631
"8": `{
2703-
"$schema": "http://json-schema.org/draft-06/schema#",
2632+
"$id": "https://schema.spaceapi.io/8.json",
2633+
"$schema": "http://json-schema.org/draft-07/schema#",
27042634
"description": "SpaceAPI 0.8",
27052635
"type": "object",
27062636
"properties": {
@@ -2800,9 +2730,11 @@ var SpaceApiSchemas = map[string]string{
28002730
"url",
28012731
"open"
28022732
]
2803-
}`,
2733+
}
2734+
`,
28042735
"9": `{
2805-
"$schema": "http://json-schema.org/draft-06/schema#",
2736+
"$id": "https://schema.spaceapi.io/9.json",
2737+
"$schema": "http://json-schema.org/draft-07/schema#",
28062738
"description": "SpaceAPI 0.9",
28072739
"type": "object",
28082740
"properties": {
@@ -2940,5 +2872,6 @@ var SpaceApiSchemas = map[string]string{
29402872
"url",
29412873
"open"
29422874
]
2943-
}`,
2875+
}
2876+
`,
29442877
}

0 commit comments

Comments
 (0)