-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
example pokeapi with new protocol #17489
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Regexes are purely illustrative and need to be workshopped: BC dates shouldn't require 4-digit years; years may have >=5 digits; etc | ||
definitions: | ||
String: | ||
type: string | ||
description: Arbitrary text | ||
BinaryData: | ||
type: string | ||
description: > | ||
Arbitrary binary data. Represented as base64-encoded strings in the JSON transport. | ||
In the future, if we support other transports, may be encoded differently. | ||
# All credit to https://stackoverflow.com/a/475217 for this pattern | ||
pattern: (?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)? | ||
Date: | ||
type: string | ||
# format: date is a superset of what we want, so we cannot use it here (e.g. it accepts 2-digit years) | ||
pattern: \d{4}-\d{2}-\d{2}( BC)? | ||
TimestampWithTimezone: | ||
type: string | ||
# format: date-time is a superset of what we want, so we cannot use it here (e.g. it accepts 2-digit years) | ||
pattern: \d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{1,2}(:\d{2})?)( BC)? | ||
description: An instant in time. Frequently simply referred to as just a timestamp, or timestamptz. | ||
TimestampWithoutTimezone: | ||
type: string | ||
pattern: \d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(\.\d+)?( BC)? | ||
description: Also known as a localdatetime, or just datetime. | ||
TimeWithTimezone: | ||
type: string | ||
pattern: \d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{1,2}(:\d{2})?) | ||
TimeWithoutTimezone: | ||
type: string | ||
pattern: \d{2}:\d{2}:\d{2}(\.\d+)? | ||
Number: | ||
type: string | ||
# Note the mix of regex validation for normal numbers, and enum validation for special values | ||
oneOf: | ||
- pattern: -?(0|[0-9]\d*)(\.\d+)? | ||
- enum: | ||
- Infinity | ||
- -Infinity | ||
- NaN | ||
Integer: | ||
type: string | ||
oneOf: | ||
- pattern: -?(0|[0-9]\d*) | ||
- enum: | ||
- Infinity | ||
- -Infinity | ||
- NaN | ||
Boolean: | ||
# Note the direct usage of a primitive boolean rather than string. Unlike Numbers and Integers, we don't expect unusual values here. | ||
type: boolean |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,45 +3,45 @@ | |
"type": "object", | ||
"properties": { | ||
"id": { | ||
"type": ["null", "integer"] | ||
"$ref": "WellKnownTypes.json#definitions/Integer" | ||
}, | ||
"name": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
}, | ||
"base_experience": { | ||
"type": ["null", "integer"] | ||
"$ref": "WellKnownTypes.json#definitions/Integer" | ||
}, | ||
"height": { | ||
"type": ["null", "integer"] | ||
"$ref": "WellKnownTypes.json#definitions/Integer" | ||
}, | ||
"is_default ": { | ||
"type": ["null", "boolean"] | ||
"$ref": "WellKnownTypes.json#definitions/Boolean" | ||
}, | ||
"order": { | ||
"type": ["null", "integer"] | ||
"$ref": "WellKnownTypes.json#definitions/Integer" | ||
}, | ||
"weight": { | ||
"type": ["null", "integer"] | ||
"$ref": "WellKnownTypes.json#definitions/Integer" | ||
}, | ||
"abilities": { | ||
"type": ["null", "array"], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as seen here: non-primitive types (arrays, objects, oneof, etc) are not defined in WellKnownTypes, because they need additional configuration to fully describe their contents |
||
"items": { | ||
"type": ["null", "object"], | ||
"properties": { | ||
"is_hidden": { | ||
"type": ["null", "boolean"] | ||
"$ref": "WellKnownTypes.json#definitions/Boolean" | ||
}, | ||
"slot": { | ||
"type": ["null", "integer"] | ||
"$ref": "WellKnownTypes.json#definitions/Integer" | ||
}, | ||
"ability": { | ||
"type": ["null", "object"], | ||
"properties": { | ||
"name": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
}, | ||
"url": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
} | ||
} | ||
} | ||
|
@@ -54,10 +54,10 @@ | |
"type": ["null", "object"], | ||
"properties": { | ||
"name": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
}, | ||
"url": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
} | ||
} | ||
} | ||
|
@@ -68,16 +68,16 @@ | |
"type": ["null", "object"], | ||
"properties": { | ||
"game_index": { | ||
"type": ["null", "integer"] | ||
"$ref": "WellKnownTypes.json#definitions/Integer" | ||
}, | ||
"version": { | ||
"type": ["null", "object"], | ||
"properties": { | ||
"name": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
}, | ||
"url": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
} | ||
} | ||
} | ||
|
@@ -93,10 +93,10 @@ | |
"type": ["null", "object"], | ||
"properties": { | ||
"name": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
}, | ||
"url": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
} | ||
} | ||
}, | ||
|
@@ -109,15 +109,15 @@ | |
"type": ["null", "object"], | ||
"properties": { | ||
"name": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
}, | ||
"url": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
} | ||
} | ||
}, | ||
"rarity": { | ||
"type": ["null", "integer"] | ||
"$ref": "WellKnownTypes.json#definitions/Integer" | ||
} | ||
} | ||
} | ||
|
@@ -126,7 +126,7 @@ | |
} | ||
}, | ||
"location_area_encounters": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
}, | ||
"moves": { | ||
"type": ["null", "array"], | ||
|
@@ -137,10 +137,10 @@ | |
"type": ["null", "object"], | ||
"properties": { | ||
"name": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
}, | ||
"url": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
} | ||
} | ||
}, | ||
|
@@ -153,26 +153,26 @@ | |
"type": ["null", "object"], | ||
"properties": { | ||
"name": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
}, | ||
"url": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
} | ||
} | ||
}, | ||
"version_group": { | ||
"type": ["null", "object"], | ||
"properties": { | ||
"name": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
}, | ||
"url": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
} | ||
} | ||
}, | ||
"level_learned_at": { | ||
"type": ["null", "integer"] | ||
"$ref": "WellKnownTypes.json#definitions/Integer" | ||
} | ||
} | ||
} | ||
|
@@ -184,39 +184,39 @@ | |
"type": ["null", "object"], | ||
"properties": { | ||
"front_default": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
}, | ||
"front_shiny": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
}, | ||
"front_female": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
}, | ||
"front_shiny_female": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
}, | ||
"back_default": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
}, | ||
"back_shiny": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
}, | ||
"back_female": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
}, | ||
"back_shiny_female": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
} | ||
} | ||
}, | ||
"species": { | ||
"type": ["null", "object"], | ||
"properties": { | ||
"name": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
}, | ||
"url": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
} | ||
} | ||
}, | ||
|
@@ -229,18 +229,18 @@ | |
"type": ["null", "object"], | ||
"properties": { | ||
"name": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
}, | ||
"url": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
} | ||
} | ||
}, | ||
"effort": { | ||
"type": ["null", "integer"] | ||
"$ref": "WellKnownTypes.json#definitions/Integer" | ||
}, | ||
"base_stat": { | ||
"type": ["null", "integer"] | ||
"$ref": "WellKnownTypes.json#definitions/Integer" | ||
} | ||
} | ||
} | ||
|
@@ -251,16 +251,16 @@ | |
"type": ["null", "object"], | ||
"properties": { | ||
"slot": { | ||
"type": ["null", "integer"] | ||
"$ref": "WellKnownTypes.json#definitions/Integer" | ||
}, | ||
"type": { | ||
"type": ["null", "object"], | ||
"properties": { | ||
"name": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
}, | ||
"url": { | ||
"type": ["null", "string"] | ||
"$ref": "WellKnownTypes.json#definitions/String" | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file is just the JSON-ified version of WellKnownTypes.yaml. In the real usage, this file will be provided as part of the CDK - I'm copying it in manually because I don't want to set up the full yaml -> json -> copy pipeline just for this example. |
||
"definitions": { | ||
"String": { | ||
"type": "string", | ||
"description": "Arbitrary text" | ||
}, | ||
"BinaryData": { | ||
"type": "string", | ||
"description": "Arbitrary binary data. Represented as base64-encoded strings in the JSON transport. In the future, if we support other transports, may be encoded differently.\n", | ||
"pattern": "(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?" | ||
}, | ||
"Date": { | ||
"type": "string", | ||
"pattern": "\\d{4}-\\d{2}-\\d{2}( BC)?" | ||
}, | ||
"TimestampWithTimezone": { | ||
"type": "string", | ||
"pattern": "\\d{4}-\\d{2}-\\d{2}[T ]\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{1,2}(:\\d{2})?)( BC)?", | ||
"description": "An instant in time. Frequently simply referred to as just a timestamp, or timestamptz." | ||
}, | ||
"TimestampWithoutTimezone": { | ||
"type": "string", | ||
"pattern": "\\d{4}-\\d{2}-\\d{2}[T ]\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?( BC)?", | ||
"description": "Also known as a localdatetime, or just datetime." | ||
}, | ||
"TimeWithTimezone": { | ||
"type": "string", | ||
"pattern": "\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{1,2}(:\\d{2})?)" | ||
}, | ||
"TimeWithoutTimezone": { | ||
"type": "string", | ||
"pattern": "\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?" | ||
}, | ||
"Number": { | ||
"type": "string", | ||
"oneOf": [ | ||
{ | ||
"pattern": "-?(0|[0-9]\\d*)(\\.\\d+)?" | ||
}, | ||
{ | ||
"enum": ["Infinity", "-Infinity", "NaN"] | ||
} | ||
] | ||
}, | ||
"Integer": { | ||
"type": "string", | ||
"oneOf": [ | ||
{ | ||
"pattern": "-?(0|[0-9]\\d*)" | ||
}, | ||
{ | ||
"enum": ["Infinity", "-Infinity", "NaN"] | ||
} | ||
] | ||
}, | ||
"Boolean": { | ||
"type": "boolean" | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null
is redundant: these properties aren'trequired
, so the source can just not set them at all.If we find that sources actually want to output
{"id": null}
, then we can always update the well-known types to usetype: [null, integer]
.