From 383a6ee7f7fefd14f9bcc3ce106d2fd42cc9f52b Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 3 Oct 2024 17:20:28 -0700 Subject: [PATCH 1/7] comparison script for yaml and json files --- scripts/compare | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 scripts/compare diff --git a/scripts/compare b/scripts/compare new file mode 100755 index 0000000000..9fd127d7e0 --- /dev/null +++ b/scripts/compare @@ -0,0 +1,40 @@ +#!/usr/bin/env perl +# vim: set ts=8 sts=2 sw=2 tw=100 et : + +# given a filename base, compare the .yaml and .json versions of the file for differences. +# to run: +# apt-get libjson-schema-modern-perl # (or equivalent on your distribution) +# scripts/compare schemas/v3.0/schema +# scripts/compare schemas/v3.1/schema +# scripts/compare schemas/v3.1/schema-base + +# Author: Karen Etheridge - karen@etheridge.ca, ether@cpan.org +# see also https://github.com/karenetheridge/JSON-Schema-Modern + +use 5.020; +use warnings; +use Path::Tiny; +use YAML::PP; +use JSON::Schema::Modern (); +use JSON::Schema::Modern::Utilities 0.591 'is_equal'; + +my $base = shift; # the filename, without .yaml or .json extension + +my $yaml_decoder = YAML::PP->new(boolean => 'JSON::PP'); +my $json_decoder = JSON::Schema::Modern::_JSON_BACKEND()->new->utf8(1); + +my $yaml_path = path($base.'.yaml'); +my $json_path = path($base.'.json'); + +my $yaml_data = $yaml_decoder->load_string($yaml_path->slurp_raw); +my $json_data = $json_decoder->decode($json_path->slurp_raw); + +if (not is_equal($yaml_data, $json_data, my $state = {})) { + say "$yaml_path and $json_path are not identical."; + say "first difference is at $state->{path}: $state->{error}"; + exit 1; +} +else { + say "files are identical."; + exit 0; +} From e81f01676ad8af9937fa79bc49282851e4da755b Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 3 Oct 2024 17:33:54 -0700 Subject: [PATCH 2/7] yaml2json perl port --- scripts/yaml2json/yaml2json.pl | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 scripts/yaml2json/yaml2json.pl diff --git a/scripts/yaml2json/yaml2json.pl b/scripts/yaml2json/yaml2json.pl new file mode 100644 index 0000000000..72706c3fa2 --- /dev/null +++ b/scripts/yaml2json/yaml2json.pl @@ -0,0 +1,8 @@ +#!/bin/env perl +use strict; +use warnings; +use YAML::XS; +use JSON::PP; + +print JSON::PP->new->pretty->indent_length(2)->canonical->encode(Load(do { local $/; <> })); +print "\n"; From a05aec4252baaaad3e3f640403f77bf338a0174b Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 3 Oct 2024 16:56:05 -0700 Subject: [PATCH 3/7] port PR#3258 schema changes to json --- schemas/v3.0/schema.json | 158 ++++++++++++++++++++------------------- 1 file changed, 82 insertions(+), 76 deletions(-) diff --git a/schemas/v3.0/schema.json b/schemas/v3.0/schema.json index 6a175a4f63..2c3441f7bf 100644 --- a/schemas/v3.0/schema.json +++ b/schemas/v3.0/schema.json @@ -1160,94 +1160,100 @@ }, { "$ref": "#/definitions/SchemaXORContent" - }, - { - "$ref": "#/definitions/ParameterLocation" } - ] - }, - "ParameterLocation": { - "description": "Parameter location", + ], "oneOf": [ { - "description": "Parameter in path", - "required": [ - "required" - ], - "properties": { - "in": { - "enum": [ - "path" - ] - }, - "style": { - "enum": [ - "matrix", - "label", - "simple" - ], - "default": "simple" - }, - "required": { - "enum": [ - true - ] - } - } + "$ref": "#/definitions/PathParameter" }, { - "description": "Parameter in query", - "properties": { - "in": { - "enum": [ - "query" - ] - }, - "style": { - "enum": [ - "form", - "spaceDelimited", - "pipeDelimited", - "deepObject" - ], - "default": "form" - } - } + "$ref": "#/definitions/QueryParameter" }, { - "description": "Parameter in header", - "properties": { - "in": { - "enum": [ - "header" - ] - }, - "style": { - "enum": [ - "simple" - ], - "default": "simple" - } - } + "$ref": "#/definitions/HeaderParameter" }, { - "description": "Parameter in cookie", - "properties": { - "in": { - "enum": [ - "cookie" - ] - }, - "style": { - "enum": [ - "form" - ], - "default": "form" - } - } + "$ref": "#/definitions/CookieParameter" } ] }, + "PathParameter": { + "description": "Parameter in path", + "required": [ + "required" + ], + "properties": { + "in": { + "enum": [ + "path" + ] + }, + "style": { + "enum": [ + "matrix", + "label", + "simple" + ], + "default": "simple" + }, + "required": { + "enum": [ + true + ] + } + } + }, + "QueryParameter": { + "description": "Parameter in query", + "properties": { + "in": { + "enum": [ + "query" + ] + }, + "style": { + "enum": [ + "form", + "spaceDelimited", + "pipeDelimited", + "deepObject" + ], + "default": "form" + } + } + }, + "HeaderParameter": { + "description": "Parameter in header", + "properties": { + "in": { + "enum": [ + "header" + ] + }, + "style": { + "enum": [ + "simple" + ], + "default": "simple" + } + } + }, + "CookieParameter": { + "description": "Parameter in cookie", + "properties": { + "in": { + "enum": [ + "cookie" + ] + }, + "style": { + "enum": [ + "form" + ], + "default": "form" + } + } + }, "RequestBody": { "type": "object", "required": [ From 00d66f0c48fa7d1b7a134187a0c523f52776c8e4 Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 3 Oct 2024 17:08:41 -0700 Subject: [PATCH 4/7] port PR#2127 schema changes to json --- schemas/v3.0/schema.json | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/schemas/v3.0/schema.json b/schemas/v3.0/schema.json index 2c3441f7bf..fdee707e8a 100644 --- a/schemas/v3.0/schema.json +++ b/schemas/v3.0/schema.json @@ -810,6 +810,30 @@ "description": { "type": "string" }, + "get": { + "$ref": "#/definitions/Operation" + }, + "put": { + "$ref": "#/definitions/Operation" + }, + "post": { + "$ref": "#/definitions/Operation" + }, + "delete": { + "$ref": "#/definitions/Operation" + }, + "options": { + "$ref": "#/definitions/Operation" + }, + "head": { + "$ref": "#/definitions/Operation" + }, + "patch": { + "$ref": "#/definitions/Operation" + }, + "trace": { + "$ref": "#/definitions/Operation" + }, "servers": { "type": "array", "items": { @@ -832,9 +856,6 @@ } }, "patternProperties": { - "^(get|put|post|delete|options|head|patch|trace)$": { - "$ref": "#/definitions/Operation" - }, "^x-": { } }, From 559500b02370750c2ada5b998d5d7ef6a5133b2f Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 3 Oct 2024 17:38:03 -0700 Subject: [PATCH 5/7] whitespace --- schemas/v3.0/schema.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/schemas/v3.0/schema.yaml b/schemas/v3.0/schema.yaml index 0123b9f645..d9a79ac49a 100644 --- a/schemas/v3.0/schema.yaml +++ b/schemas/v3.0/schema.yaml @@ -43,6 +43,7 @@ definitions: '^\$ref$': type: string format: uri-reference + Info: type: object required: @@ -66,7 +67,6 @@ definitions: '^x-': {} additionalProperties: false - Contact: type: object properties: @@ -593,7 +593,6 @@ definitions: minProperties: 1 additionalProperties: false - SecurityRequirement: type: object additionalProperties: From bc55266746faca34080726d62c6538345e9c4137 Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 3 Oct 2024 17:37:31 -0700 Subject: [PATCH 6/7] bump spec version in 3.0.x schemas --- schemas/v3.0/schema.json | 2 +- schemas/v3.0/schema.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/schemas/v3.0/schema.json b/schemas/v3.0/schema.json index fdee707e8a..178dcdc47c 100644 --- a/schemas/v3.0/schema.json +++ b/schemas/v3.0/schema.json @@ -1,7 +1,7 @@ { "id": "https://spec.openapis.org/oas/3.0/schema/2021-09-28", "$schema": "http://json-schema.org/draft-04/schema#", - "description": "The description of OpenAPI v3.0.x documents, as defined by https://spec.openapis.org/oas/v3.0.3", + "description": "The description of OpenAPI v3.0.x documents, as defined by https://spec.openapis.org/oas/v3.0.4", "type": "object", "required": [ "openapi", diff --git a/schemas/v3.0/schema.yaml b/schemas/v3.0/schema.yaml index d9a79ac49a..96a4cdc796 100644 --- a/schemas/v3.0/schema.yaml +++ b/schemas/v3.0/schema.yaml @@ -1,6 +1,6 @@ id: https://spec.openapis.org/oas/3.0/schema/2021-09-28 $schema: http://json-schema.org/draft-04/schema# -description: The description of OpenAPI v3.0.x documents, as defined by https://spec.openapis.org/oas/v3.0.3 +description: The description of OpenAPI v3.0.x documents, as defined by https://spec.openapis.org/oas/v3.0.4 type: object required: - openapi From b285b783427dacb45e63246e2b1c0fee252ce4c2 Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 3 Oct 2024 17:37:56 -0700 Subject: [PATCH 7/7] bump release date (this should be updated one final time at release time) --- schemas/v3.0/schema.json | 2 +- schemas/v3.0/schema.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/schemas/v3.0/schema.json b/schemas/v3.0/schema.json index 178dcdc47c..5cb072b679 100644 --- a/schemas/v3.0/schema.json +++ b/schemas/v3.0/schema.json @@ -1,5 +1,5 @@ { - "id": "https://spec.openapis.org/oas/3.0/schema/2021-09-28", + "id": "https://spec.openapis.org/oas/3.0/schema/2024-10-10", "$schema": "http://json-schema.org/draft-04/schema#", "description": "The description of OpenAPI v3.0.x documents, as defined by https://spec.openapis.org/oas/v3.0.4", "type": "object", diff --git a/schemas/v3.0/schema.yaml b/schemas/v3.0/schema.yaml index 96a4cdc796..f5f10bd2ef 100644 --- a/schemas/v3.0/schema.yaml +++ b/schemas/v3.0/schema.yaml @@ -1,4 +1,4 @@ -id: https://spec.openapis.org/oas/3.0/schema/2021-09-28 +id: https://spec.openapis.org/oas/3.0/schema/2024-10-10 $schema: http://json-schema.org/draft-04/schema# description: The description of OpenAPI v3.0.x documents, as defined by https://spec.openapis.org/oas/v3.0.4 type: object