Skip to content

Commit f39ef60

Browse files
Fix jsonSchemaDialect should not have a default value (issue #55) (#71)
Changed the default for OpenAPI.json_schema_dialect from 'https://json-schema.org/draft/2020-12/schema' to None so that the field is omitted from serialized output unless explicitly set. Updated all test expectations accordingly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent a0d7a3c commit f39ef60

File tree

3 files changed

+5
-19
lines changed

3 files changed

+5
-19
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121
- Fix [#49](https://github.com/Neoteroi/essentials-openapi/issues/49): support `$ref`
2222
values of the form `file.yaml#/fragment/path` (external file with JSON Pointer
2323
fragment), reported by @mbklein.
24+
- Fix [#55](https://github.com/Neoteroi/essentials-openapi/issues/55): `jsonSchemaDialect`
25+
is not required and should not have a default value.
2426

2527
## [1.3.0] - 2025-11-19
2628

openapidocs/v3.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -957,8 +957,8 @@ class OpenAPI(OpenAPIRoot):
957957
Attributes:
958958
openapi (str): The semantic version number of the OpenAPI Specification version.
959959
info (Info | None): Metadata about the API.
960-
json_schema_dialect (str): The default value for the $schema keyword within Schema Objects contained
961-
within this OAS document.
960+
json_schema_dialect (str | None): The default value for the $schema keyword within Schema Objects contained
961+
within this OAS document. Optional; if omitted, the dialect is not declared.
962962
paths (dict[str, PathItem] | None): The available paths and operations for the API.
963963
servers (list[Server] | None): An array of Server Objects that provide connectivity information
964964
to a target server.
@@ -971,7 +971,7 @@ class OpenAPI(OpenAPIRoot):
971971

972972
openapi: str = "3.1.0"
973973
info: Info | None = None
974-
json_schema_dialect: str = "https://json-schema.org/draft/2020-12/schema"
974+
json_schema_dialect: str | None = None
975975
paths: dict[str, PathItem] | None = None
976976
servers: list[Server] | None = None
977977
components: Components | None = None

tests/test_v3.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ def yaml(self) -> str:
172172
info:
173173
title: Cats API
174174
version: 1.0.0
175-
jsonSchemaDialect: https://json-schema.org/draft/2020-12/schema
176175
paths:
177176
/:
178177
summary: summary
@@ -214,7 +213,6 @@ def json(self) -> str:
214213
"title": "Cats API",
215214
"version": "1.0.0"
216215
},
217-
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
218216
"paths": {
219217
"/": {
220218
"summary": "summary"
@@ -613,7 +611,6 @@ def yaml(self) -> str:
613611
info:
614612
title: Weather API
615613
version: 0.0.0-alpha
616-
jsonSchemaDialect: https://json-schema.org/draft/2020-12/schema
617614
paths:
618615
/weather:
619616
summary: Call current weather data for one location
@@ -683,7 +680,6 @@ def json(self) -> str:
683680
"title": "Weather API",
684681
"version": "0.0.0-alpha"
685682
},
686-
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
687683
"paths": {
688684
"/weather": {
689685
"summary": "Call current weather data for one location",
@@ -831,7 +827,6 @@ def yaml(self) -> str:
831827
info:
832828
title: Example API
833829
version: 0.0.0-alpha
834-
jsonSchemaDialect: https://json-schema.org/draft/2020-12/schema
835830
paths:
836831
/:
837832
summary: Test the example snake_case properness
@@ -869,7 +864,6 @@ def json(self) -> str:
869864
"title": "Example API",
870865
"version": "0.0.0-alpha"
871866
},
872-
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
873867
"paths": {
874868
"/": {
875869
"summary": "Test the example snake_case properness",
@@ -976,7 +970,6 @@ def yaml(self) -> str:
976970
info:
977971
title: Example API
978972
version: 0.0.0-alpha
979-
jsonSchemaDialect: https://json-schema.org/draft/2020-12/schema
980973
paths:
981974
/:
982975
summary: Test the example snake_case properness
@@ -1022,7 +1015,6 @@ def json(self) -> str:
10221015
"title": "Example API",
10231016
"version": "0.0.0-alpha"
10241017
},
1025-
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
10261018
"paths": {
10271019
"/": {
10281020
"summary": "Test the example snake_case properness",
@@ -1153,7 +1145,6 @@ def yaml(self) -> str:
11531145
info:
11541146
title: Example API
11551147
version: 0.0.0-alpha
1156-
jsonSchemaDialect: https://json-schema.org/draft/2020-12/schema
11571148
paths:
11581149
/:
11591150
summary: Test the example snake_case properness
@@ -1208,7 +1199,6 @@ def json(self) -> str:
12081199
"title": "Example API",
12091200
"version": "0.0.0-alpha"
12101201
},
1211-
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
12121202
"paths": {
12131203
"/": {
12141204
"summary": "Test the example snake_case properness",
@@ -1399,7 +1389,6 @@ def yaml(self) -> str:
13991389
info:
14001390
title: Example API
14011391
version: 0.0.0-alpha
1402-
jsonSchemaDialect: https://json-schema.org/draft/2020-12/schema
14031392
paths:
14041393
/:
14051394
description: Lorem ipsum dolor sit amet
@@ -1499,7 +1488,6 @@ def json(self) -> str:
14991488
"title": "Example API",
15001489
"version": "0.0.0-alpha"
15011490
},
1502-
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
15031491
"paths": {
15041492
"/": {
15051493
"description": "Lorem ipsum dolor sit amet",
@@ -1697,7 +1685,6 @@ def yaml(self) -> str:
16971685
info:
16981686
title: Example API
16991687
version: 0.0.0-alpha
1700-
jsonSchemaDialect: https://json-schema.org/draft/2020-12/schema
17011688
paths:
17021689
/:
17031690
summary: Test the example snake_case properness
@@ -1743,7 +1730,6 @@ def json(self) -> str:
17431730
"title": "Example API",
17441731
"version": "0.0.0-alpha"
17451732
},
1746-
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
17471733
"paths": {
17481734
"/": {
17491735
"summary": "Test the example snake_case properness",
@@ -1880,7 +1866,6 @@ def get_instance(self) -> Any:
18801866
def yaml(self) -> str:
18811867
return """
18821868
openapi: 3.1.0
1883-
jsonSchemaDialect: https://json-schema.org/draft/2020-12/schema
18841869
servers:
18851870
- url: https://{username}.gigantic-server.com:{port}/{basePath}
18861871
description: The production API server
@@ -1902,7 +1887,6 @@ def json(self) -> str:
19021887
return """
19031888
{
19041889
"openapi": "3.1.0",
1905-
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
19061890
"servers": [
19071891
{
19081892
"url": "https://{username}.gigantic-server.com:{port}/{basePath}",

0 commit comments

Comments
 (0)