Skip to content
Merged
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
29 changes: 22 additions & 7 deletions ir/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,28 @@ package ir
// "preserved" is now "unmodeled". A consumer pinned to 0.2.0 finds no key it
// recognizes and drops every unmodeled construct in silence.
//
// In flight: the stack/* branches (dexpace/morphic #436–#442) change the shape
// under this version — Payload gains "required", Parameter a non-omitempty
// "provenance", and more above them — and the bump to 0.4.0 lands with the
// top of that stack (#442). The stack squash-merges bottom-up, so a main
// between the first of those and the last carries a 0.4.0 shape stamped
// 0.3.0; this paragraph goes with the bump.
const IRVersion = "0.3.0"
// 0.4.0 covers six shape changes made together, all of them closing a gap a
// consumer had to read around rather than adding a capability:
//
// - ErrorCase becomes Response's sibling: Type is REMOVED, and Name, Payload
// and Headers take its place. A consumer pinned to 0.3.0 finds no "type" on
// an error case and cannot reach its models at all; one that reads the new
// fields gets the status spelling, the headers and every media type, which
// 0.3.0 dumped into Unmodeled whatever their arity.
// - Payload gains Required. Body optionality stopped being an inverted
// Unmodeled sentinel read by absence, so a consumer that still reads
// "openapi:required" now finds nothing and reads every body as required.
// - Parameter gains Provenance, non-omitempty, and with it x-sunset promotion
// at the parameter position.
// - Deprecation gains RemovalDate. x-sunset promotes into it rather than into
// RemovalVersion, so a consumer reading a removal date off the version field
// now finds it empty.
// - Encoding gains Schema, giving contentSchema a home at scalar positions.
// - Constraints.ExclusiveMin and ExclusiveMax change from bool to a decimal
// string carrying the bound itself, so the two dialects' exclusive bounds no
// longer lose one keyword to the other. The JSON type of both keys changed;
// a consumer decoding them as booleans fails rather than degrades.
const IRVersion = "0.4.0"

// CompatibleVersion reports whether a document stamped version can be read by
// this build. It is the predicate behind the compatibility policy in
Expand Down
13 changes: 10 additions & 3 deletions ir/document_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,16 @@ func TestCompatibleVersion(t *testing.T) {
}{
{"this build's version", ir.IRVersion, true},
{"absent", "", false},
{"an earlier generation", "0.1.0", false},
{"a later generation", "0.4.0", false},
{"a differing patch", "0.3.1", false},
// These three are literals spelled against the CURRENT IRVersion, and
// nothing makes them follow it: every bump must re-anchor them by hand.
// The neighbour rows are the point of the test, so a bump that leaves
// them behind stops testing what they name — at 0.4.0 the old "later
// generation" literal WAS the current version, and the row asserted the
// build rejects its own documents. The rows below spell IRVersion
// directly and need no such maintenance.
{"the generation before this one", "0.3.0", false},
{"a later generation", "0.5.0", false},
{"a differing patch", "0.4.1", false},
{"a prerelease of this version", ir.IRVersion + "-rc.1", false},
{"padded with whitespace", " " + ir.IRVersion + " ", false},
{"not a version at all", "99.99.99-bogus", false},
Expand Down
6 changes: 5 additions & 1 deletion ir/irverify/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ func TestVerify_IncompatibleIRVersionIsAViolation(t *testing.T) {
{"older generation", "0.1.0"},
{"newer generation", "99.0.0"},
{"not a version", "99.99.99-bogus"},
{"whitespace around the current version", " 0.3.0 "},
// Spelled relative to IRVersion so it MOVES WITH IT. A literal stops
// testing the padding the moment the constant is bumped past it: the
// bare version is then rejected for being a prior generation, and the
// row passes whether or not whitespace is tolerated.
{"whitespace around the current version", " " + ir.IRVersion + " "},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "AllOfBooleanBranch",
"version": "1.0.0",
"docs": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "AllOfConflictingType",
"version": "1.0.0",
"docs": {},
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/allof-inheritance.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "AllOfInheritance",
"version": "1.0.0",
"docs": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "AllOfInlineMerge",
"version": "1.0.0",
"docs": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "AllOfInlineResidue",
"version": "1.0.0",
"docs": {},
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/allof-mixins.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "AllOfMixins",
"version": "1.0.0",
"docs": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "AllOfOneOfCooccurrence",
"version": "1.0.0",
"docs": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "AllOfRefBranchSiblings",
"version": "1.0.0",
"docs": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "AllOfRequiredOnly",
"version": "1.0.0",
"docs": {},
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/anyof-untagged.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "AnyOfUntagged",
"version": "1.0.0",
"docs": {},
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/callbacks.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "Callbacks",
"version": "1.0.0",
"docs": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "CoDeclaredKeywords",
"version": "1.0.0",
"docs": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "CoDeclaredSchemaContent",
"version": "1.0.0",
"docs": {},
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/component-reuse.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "Component Reuse",
"version": "1",
"docs": {},
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/constraints.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "Constraints",
"version": "1.0.0",
"docs": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "ContentVocabulary",
"version": "1.0.0",
"docs": {},
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/defaults.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "Defaults",
"version": "1.0.0",
"docs": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "DependentRequired",
"version": "1.0.0",
"docs": {},
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/deprecation.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "Deprecation",
"version": "1.0.0",
"docs": {},
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/dialect-keywords.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "DialectKeywords",
"version": "1.0.0",
"docs": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "DiscriminatorDefaultMapping",
"version": "1.0.0",
"docs": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "DiscriminatorInheritance",
"version": "1.0.0",
"docs": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "DiscriminatorTransitive",
"version": "1.0.0",
"docs": {},
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/docs-summary-desc.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "DocsSummaryDesc",
"version": "1.0.0",
"docs": {
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/dynamic-ref.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "DynamicRef",
"version": "1.0.0",
"docs": {},
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/empty-enum.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "EmptyEnum",
"version": "1.0.0",
"docs": {},
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/empty-names.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "Empty Names",
"version": "1.0.0",
"docs": {},
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/encoding-byte.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "EncodingByte",
"version": "1.0.0",
"docs": {},
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/enum-numeric.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "EnumNumeric",
"version": "1.0.0",
"docs": {},
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/enum-string.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "EnumString",
"version": "1.0.0",
"docs": {},
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/examples.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "Examples",
"version": "1.0.0",
"docs": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "ExtensionPromotion",
"version": "1.0.0",
"docs": {},
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/extensions-x.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "ExtensionsX",
"version": "1.0.0",
"docs": {
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/file-body.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "FileBody",
"version": "1.0.0",
"docs": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "HeaderContentSchema",
"version": "1.0.0",
"docs": {},
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/http-binding.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "HTTPBinding",
"version": "1.0.0",
"docs": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "InlineAnnotations",
"version": "1.0.0",
"docs": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "InlineHoistPositions",
"version": "1.0.0",
"docs": {},
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/inline-residue.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "InlineResidue",
"version": "1.0.0",
"docs": {},
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/inline-types.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "InlineTypes",
"version": "1.0.0",
"docs": {},
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/literal-const.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "LiteralConst",
"version": "1.0.0",
"docs": {},
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/maps.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "Maps",
"version": "1.0.0",
"docs": {},
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/multi-content.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "MultiContent",
"version": "1.0.0",
"docs": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "MultipartEncoding",
"version": "1.0.0",
"docs": {},
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/named-types.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "NamedTypes",
"version": "1.0.0",
"docs": {},
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/negation-not.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "NegationNot",
"version": "1.0.0",
"docs": {},
Expand Down
2 changes: 1 addition & 1 deletion testdata/conformance/openapi/neutral-naming.golden.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"irVersion": "0.3.0",
"irVersion": "0.4.0",
"name": "Neutral.Naming API",
"version": "1.0.0",
"docs": {},
Expand Down
Loading
Loading