Skip to content

Commit bcc2224

Browse files
authored
Aligned scalar implementations with the specs, and added SpecifiedBy (#9122)
1 parent 73cc056 commit bcc2224

File tree

138 files changed

+1598
-845
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+1598
-845
lines changed

dictionary.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ accessibilities
55
agrc
66
Alderaan
77
Andi
8-
andimarek
98
ASPDEPR004
109
ASPDEPR008
1110
aspnetcore
@@ -19,6 +18,7 @@ bananacakepop
1918
bbox
2019
BCPROCKS
2120
bfnrt
21+
birthdates
2222
blazor
2323
blazorwasm
2424
Brontie
@@ -52,12 +52,14 @@ EPSG
5252
esque
5353
evolvability
5454
Fanout
55+
FFFFFFFZ
5556
fffzzz
5657
fieldset
5758
FIPS
5859
foos
5960
fricking
6061
frontends
62+
Fzzz
6163
GEOGCS
6264
Giroux
6365
GraphiQL

src/HotChocolate/Adapters/src/Adapters.Mcp.Core/Extensions/TypeExtensions.cs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,13 @@ private static bool TryGetJsonSchemaFormat(
181181

182182
format = scalarType.SpecifiedBy?.OriginalString switch
183183
{
184-
"https://scalars.graphql.org/andimarek/date-time.html" => Formats.DateTime,
185-
"https://scalars.graphql.org/andimarek/local-date.html" => Formats.Date,
184+
"https://scalars.graphql.org/chillicream/date.html" => Formats.Date,
185+
"https://scalars.graphql.org/chillicream/date-time.html" => Formats.DateTime,
186+
"https://scalars.graphql.org/chillicream/local-date.html" => Formats.Date,
187+
"https://scalars.graphql.org/chillicream/time-span.html" => Formats.Duration,
188+
"https://scalars.graphql.org/chillicream/uuid.html" => Formats.Uuid,
189+
"https://scalars.graphql.org/chillicream/uri.html" => Formats.Uri,
190+
"https://scalars.graphql.org/chillicream/url.html" => Formats.Uri,
186191
_ => null
187192
};
188193

@@ -201,10 +206,22 @@ private static bool TryGetJsonSchemaPattern(
201206

202207
pattern = scalarType.SpecifiedBy?.OriginalString switch
203208
{
204-
"https://scalars.graphql.org/andimarek/date-time.html"
205-
=> @"^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}:\d{2}(?:\.\d{1,7})?(?:[Zz]|[+-]\d{2}:\d{2})$",
206-
"https://scalars.graphql.org/andimarek/local-date.html"
209+
"https://scalars.graphql.org/chillicream/base64-string.html"
210+
=> @"^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$",
211+
"https://scalars.graphql.org/chillicream/date.html"
207212
=> @"^\d{4}-\d{2}-\d{2}$",
213+
"https://scalars.graphql.org/chillicream/date-time.html"
214+
=> @"^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:[Zz]|[+-]\d{2}:\d{2})$",
215+
"https://scalars.graphql.org/chillicream/local-date.html"
216+
=> @"^\d{4}-\d{2}-\d{2}$",
217+
"https://scalars.graphql.org/chillicream/local-date-time.html"
218+
=> @"^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?$",
219+
"https://scalars.graphql.org/chillicream/local-time.html"
220+
=> @"^\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?$",
221+
"https://scalars.graphql.org/chillicream/time-span.html"
222+
=> @"^-?P(?:\d+W|(?=\d|T(?:\d|$))(?:\d+Y)?(?:\d+M)?(?:\d+D)?(?:T(?:\d+H)?(?:\d+M)?(?:\d+(?:\.\d+)?S)?)?)$",
223+
"https://scalars.graphql.org/chillicream/uuid.html"
224+
=> @"^[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}$",
208225
_ => null
209226
};
210227

src/HotChocolate/Adapters/src/Adapters.OpenApi.AspNetCore/DynamicOpenApiDocumentTransformer.cs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,13 @@ private static OpenApiSchema CreateScalarSchema(IScalarTypeDefinition scalarType
526526
{
527527
var format = scalarType.SpecifiedBy?.OriginalString switch
528528
{
529-
"https://scalars.graphql.org/andimarek/date-time.html" => "date-time",
530-
"https://scalars.graphql.org/andimarek/local-date.html" => "date",
529+
"https://scalars.graphql.org/chillicream/date.html" => "date",
530+
"https://scalars.graphql.org/chillicream/date-time.html" => "date-time",
531+
"https://scalars.graphql.org/chillicream/local-date.html" => "date",
532+
"https://scalars.graphql.org/chillicream/time-span.html" => "duration",
533+
"https://scalars.graphql.org/chillicream/uuid.html" => "uuid",
534+
"https://scalars.graphql.org/chillicream/uri.html" => "uri",
535+
"https://scalars.graphql.org/chillicream/url.html" => "uri",
531536
_ => null
532537
};
533538

@@ -550,10 +555,22 @@ private static OpenApiSchema CreateScalarSchema(IScalarTypeDefinition scalarType
550555
{
551556
var pattern = scalarType.SpecifiedBy?.OriginalString switch
552557
{
553-
"https://scalars.graphql.org/andimarek/date-time.html"
554-
=> @"^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}:\d{2}(?:\.\d{1,7})?(?:[Zz]|[+-]\d{2}:\d{2})$",
555-
"https://scalars.graphql.org/andimarek/local-date.html"
558+
"https://scalars.graphql.org/chillicream/base64-string.html"
559+
=> @"^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$",
560+
"https://scalars.graphql.org/chillicream/date.html"
556561
=> @"^\d{4}-\d{2}-\d{2}$",
562+
"https://scalars.graphql.org/chillicream/date-time.html"
563+
=> @"^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:[Zz]|[+-]\d{2}:\d{2})$",
564+
"https://scalars.graphql.org/chillicream/local-date.html"
565+
=> @"^\d{4}-\d{2}-\d{2}$",
566+
"https://scalars.graphql.org/chillicream/local-date-time.html"
567+
=> @"^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?$",
568+
"https://scalars.graphql.org/chillicream/local-time.html"
569+
=> @"^\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?$",
570+
"https://scalars.graphql.org/chillicream/time-span.html"
571+
=> @"^-?P(?:\d+W|(?=\d|T(?:\d|$))(?:\d+Y)?(?:\d+M)?(?:\d+D)?(?:T(?:\d+H)?(?:\d+M)?(?:\d+(?:\.\d+)?S)?)?)$",
572+
"https://scalars.graphql.org/chillicream/uuid.html"
573+
=> @"^[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}$",
557574
_ => null
558575
};
559576

src/HotChocolate/Adapters/test/Adapters.Mcp.Tests/Extensions/TypeExtensionsTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ public void ToJsonSchemaBuilder_ValidValues_MatchPattern(Type type, string value
5151
[InlineData(typeof(DateTimeType), "2011-08-30")]
5252
// Seconds are not allowed for the offset.
5353
[InlineData(typeof(DateTimeType), "2011-08-30T13:22:53.108+03:30:15")]
54-
// A DateTime with 8 fractional digits.
55-
[InlineData(typeof(DateTimeType), "2011-08-30T13:22:53.12345678+03:30")]
54+
// A DateTime with 10 fractional digits.
55+
[InlineData(typeof(DateTimeType), "2011-08-30T13:22:53.1234567890+03:30")]
5656
[InlineData(typeof(LocalDateTimeType), "2018/06/11T08:46:14 pm")]
5757
[InlineData(typeof(LocalDateTimeType), "abc")]
5858
[InlineData(typeof(LocalTimeType), "08:46:14 pm")]

src/HotChocolate/Adapters/test/Adapters.Mcp.Tests/__snapshots__/IntegrationTestBase.CallTool_GetWithDefaultedVariables_ReturnsExpectedResult.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"boolean": true,
99
"byte": 1,
1010
"date": "2000-01-01",
11-
"dateTime": "2000-01-01T12:00:00.000Z",
11+
"dateTime": "2000-01-01T12:00:00Z",
1212
"decimal": 79228162514264337593543950335,
1313
"enum": "VALUE1",
1414
"float": 1.5,

src/HotChocolate/Adapters/test/Adapters.Mcp.Tests/__snapshots__/IntegrationTestBase.CallTool_GetWithNonNullableVariables_ReturnsExpectedResult.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"boolean": true,
99
"byte": 1,
1010
"date": "2000-01-01",
11-
"dateTime": "2000-01-01T12:00:00.000Z",
11+
"dateTime": "2000-01-01T12:00:00Z",
1212
"decimal": 79228162514264337593543950335,
1313
"enum": "VALUE1",
1414
"float": 1.5,

src/HotChocolate/Adapters/test/Adapters.Mcp.Tests/__snapshots__/OperationToolFactoryTests.CreateTool_WithComplexVariables_CreatesCorrectSchema_Input.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"string",
2020
"null"
2121
],
22-
"pattern": "^\\d{2}:\\d{2}:\\d{2}$",
22+
"pattern": "^\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,9})?$",
2323
"description": "field1C description",
2424
"default": "12:00:00"
2525
}
@@ -76,7 +76,7 @@
7676
"string",
7777
"null"
7878
],
79-
"pattern": "^\\d{2}:\\d{2}:\\d{2}$",
79+
"pattern": "^\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,9})?$",
8080
"description": "field1C description",
8181
"default": "12:00:00"
8282
}
@@ -157,7 +157,7 @@
157157
"string",
158158
"null"
159159
],
160-
"pattern": "^\\d{2}:\\d{2}:\\d{2}$",
160+
"pattern": "^\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,9})?$",
161161
"description": "field1C description",
162162
"default": "12:00:00"
163163
}

src/HotChocolate/Adapters/test/Adapters.Mcp.Tests/__snapshots__/OperationToolFactoryTests.CreateTool_WithComplexVariables_CreatesCorrectSchema_Output.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"string",
2929
"null"
3030
],
31-
"pattern": "^\\d{2}:\\d{2}:\\d{2}$",
31+
"pattern": "^\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,9})?$",
3232
"description": "field1C description"
3333
}
3434
},
@@ -69,7 +69,7 @@
6969
"string",
7070
"null"
7171
],
72-
"pattern": "^\\d{2}:\\d{2}:\\d{2}$",
72+
"pattern": "^\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,9})?$",
7373
"description": "field1C description"
7474
}
7575
},
@@ -130,7 +130,7 @@
130130
"string",
131131
"null"
132132
],
133-
"pattern": "^\\d{2}:\\d{2}:\\d{2}$",
133+
"pattern": "^\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,9})?$",
134134
"description": "field1C description"
135135
}
136136
},

src/HotChocolate/Adapters/test/Adapters.Mcp.Tests/__snapshots__/OperationToolFactoryTests.CreateTool_WithDefaultedVariables_CreatesCorrectSchema_Input.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@
3333
},
3434
"date": {
3535
"type": "string",
36+
"format": "date",
3637
"pattern": "^\\d{4}-\\d{2}-\\d{2}$",
3738
"description": "Date description",
3839
"default": "2000-01-01"
3940
},
4041
"dateTime": {
4142
"type": "string",
4243
"format": "date-time",
43-
"pattern": "^\\d{4}-\\d{2}-\\d{2}[Tt]\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,7})?(?:[Zz]|[+-]\\d{2}:\\d{2})$",
44+
"pattern": "^\\d{4}-\\d{2}-\\d{2}[Tt]\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,9})?(?:[Zz]|[+-]\\d{2}:\\d{2})$",
4445
"description": "DateTime description",
4546
"default": "2000-01-01T12:00:00Z"
4647
},
@@ -95,13 +96,13 @@
9596
},
9697
"localDateTime": {
9798
"type": "string",
98-
"pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}$",
99+
"pattern": "^\\d{4}-\\d{2}-\\d{2}[Tt]\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,9})?$",
99100
"description": "LocalDateTime description",
100101
"default": "2000-01-01T12:00:00"
101102
},
102103
"localTime": {
103104
"type": "string",
104-
"pattern": "^\\d{2}:\\d{2}:\\d{2}$",
105+
"pattern": "^\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,9})?$",
105106
"description": "LocalTime description",
106107
"default": "12:00:00"
107108
},
@@ -121,7 +122,7 @@
121122
"properties": {
122123
"field1C": {
123124
"type": "string",
124-
"pattern": "^\\d{2}:\\d{2}:\\d{2}$",
125+
"pattern": "^\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,9})?$",
125126
"description": "field1C description",
126127
"default": "12:00:00"
127128
}
@@ -164,6 +165,7 @@
164165
},
165166
"timeSpan": {
166167
"type": "string",
168+
"format": "duration",
167169
"pattern": "^-?P(?:\\d+W|(?=\\d|T(?:\\d|$))(?:\\d+Y)?(?:\\d+M)?(?:\\d+D)?(?:T(?:\\d+H)?(?:\\d+M)?(?:\\d+(?:\\.\\d+)?S)?)?)$",
168170
"description": "TimeSpan description",
169171
"default": "PT5M"
@@ -175,16 +177,19 @@
175177
},
176178
"uri": {
177179
"type": "string",
180+
"format": "uri",
178181
"description": "URI description",
179182
"default": "https://example.com"
180183
},
181184
"url": {
182185
"type": "string",
186+
"format": "uri",
183187
"description": "URL description",
184188
"default": "https://example.com"
185189
},
186190
"uuid": {
187191
"type": "string",
192+
"format": "uuid",
188193
"pattern": "^[\\da-fA-F]{8}-[\\da-fA-F]{4}-[\\da-fA-F]{4}-[\\da-fA-F]{4}-[\\da-fA-F]{12}$",
189194
"description": "UUID description",
190195
"default": "00000000-0000-0000-0000-000000000000"

src/HotChocolate/Adapters/test/Adapters.Mcp.Tests/__snapshots__/OperationToolFactoryTests.CreateTool_WithDefaultedVariables_CreatesCorrectSchema_Output.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@
3232
},
3333
"date": {
3434
"type": "string",
35+
"format": "date",
3536
"pattern": "^\\d{4}-\\d{2}-\\d{2}$"
3637
},
3738
"dateTime": {
3839
"type": "string",
3940
"format": "date-time",
40-
"pattern": "^\\d{4}-\\d{2}-\\d{2}[Tt]\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,7})?(?:[Zz]|[+-]\\d{2}:\\d{2})$"
41+
"pattern": "^\\d{4}-\\d{2}-\\d{2}[Tt]\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,9})?(?:[Zz]|[+-]\\d{2}:\\d{2})$"
4142
},
4243
"decimal": {
4344
"type": "number"
@@ -74,11 +75,11 @@
7475
},
7576
"localDateTime": {
7677
"type": "string",
77-
"pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}$"
78+
"pattern": "^\\d{4}-\\d{2}-\\d{2}[Tt]\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,9})?$"
7879
},
7980
"localTime": {
8081
"type": "string",
81-
"pattern": "^\\d{2}:\\d{2}:\\d{2}$"
82+
"pattern": "^\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,9})?$"
8283
},
8384
"long": {
8485
"type": "integer"
@@ -94,7 +95,7 @@
9495
"properties": {
9596
"field1C": {
9697
"type": "string",
97-
"pattern": "^\\d{2}:\\d{2}:\\d{2}$",
98+
"pattern": "^\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,9})?$",
9899
"description": "field1C description"
99100
}
100101
},
@@ -125,19 +126,23 @@
125126
},
126127
"timeSpan": {
127128
"type": "string",
129+
"format": "duration",
128130
"pattern": "^-?P(?:\\d+W|(?=\\d|T(?:\\d|$))(?:\\d+Y)?(?:\\d+M)?(?:\\d+D)?(?:T(?:\\d+H)?(?:\\d+M)?(?:\\d+(?:\\.\\d+)?S)?)?)$"
129131
},
130132
"unknown": {
131133
"type": "string"
132134
},
133135
"uri": {
134-
"type": "string"
136+
"type": "string",
137+
"format": "uri"
135138
},
136139
"url": {
137-
"type": "string"
140+
"type": "string",
141+
"format": "uri"
138142
},
139143
"uuid": {
140144
"type": "string",
145+
"format": "uuid",
141146
"pattern": "^[\\da-fA-F]{8}-[\\da-fA-F]{4}-[\\da-fA-F]{4}-[\\da-fA-F]{4}-[\\da-fA-F]{12}$"
142147
}
143148
},

0 commit comments

Comments
 (0)