Skip to content

Commit 43bae11

Browse files
committed
Fix some warnings
1 parent 07c9d7d commit 43bae11

File tree

3 files changed

+221
-4
lines changed

3 files changed

+221
-4
lines changed

test/OpenApiNSwagEndToEndTests/ModelValidation/ModelValidationTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public async Task Out_of_range_integer_should_return_an_error(int age)
214214
}
215215

216216
[Fact]
217-
public async Task Invalid_url_should_return_an_error()
217+
public async Task Invalid_uri_should_return_an_error()
218218
{
219219
// Arrange
220220
Fingerprint fingerprint = _fakers.Fingerprint.Generate();
@@ -247,7 +247,7 @@ public async Task Invalid_url_should_return_an_error()
247247
}
248248

249249
[Fact]
250-
public async Task Invalid_url_as_string_should_return_an_error()
250+
public async Task Invalid_url_should_return_an_error()
251251
{
252252
// Arrange
253253
Fingerprint fingerprint = _fakers.Fingerprint.Generate();
@@ -438,7 +438,7 @@ public async Task Fitting_all_the_constraints_should_work()
438438
BackgroundPicture = new Uri(fingerprint.BackgroundPicture!),
439439
NextRevalidation = "02:00:00",
440440
ValidatedAt = fingerprint.ValidatedAt!.Value.ToUniversalTime(),
441-
// TODO: ValidatedDateAt = new DateTimeOffset(fingerprint.ValidatedDateAt!.Value.ToDateTime(new TimeOnly()).ToUniversalTime()),
441+
ValidatedDateAt = new DateTimeOffset(fingerprint.ValidatedDateAt!.Value.ToDateTime(new TimeOnly()).ToUniversalTime()),
442442
ValidatedTimeAt = fingerprint.ValidatedTimeAt!.Value.ToTimeSpan()
443443
}
444444
}

test/OpenApiTests/ModelValidation/GeneratedSwagger/swagger.g.json

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,109 @@
123123
}
124124
}
125125
}
126+
},
127+
"/fingerprints/{id}": {
128+
"patch": {
129+
"tags": [
130+
"fingerprints"
131+
],
132+
"summary": "Updates an existing fingerprint.",
133+
"operationId": "patchFingerprint",
134+
"parameters": [
135+
{
136+
"name": "id",
137+
"in": "path",
138+
"description": "The identifier of the fingerprint to update.",
139+
"required": true,
140+
"schema": {
141+
"type": "string"
142+
}
143+
},
144+
{
145+
"name": "query",
146+
"in": "query",
147+
"description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.",
148+
"schema": {
149+
"type": "object",
150+
"additionalProperties": {
151+
"type": "string",
152+
"nullable": true
153+
},
154+
"example": ""
155+
}
156+
}
157+
],
158+
"requestBody": {
159+
"description": "The attributes and relationships of the fingerprint to update. Omitted fields are left unchanged.",
160+
"content": {
161+
"application/vnd.api+json": {
162+
"schema": {
163+
"allOf": [
164+
{
165+
"$ref": "#/components/schemas/fingerprintPatchRequestDocument"
166+
}
167+
]
168+
}
169+
}
170+
},
171+
"required": true
172+
},
173+
"responses": {
174+
"200": {
175+
"description": "The fingerprint was successfully updated, which resulted in additional changes. The updated fingerprint is returned.",
176+
"content": {
177+
"application/vnd.api+json": {
178+
"schema": {
179+
"$ref": "#/components/schemas/fingerprintPrimaryResponseDocument"
180+
}
181+
}
182+
}
183+
},
184+
"204": {
185+
"description": "The fingerprint was successfully updated, which did not result in additional changes."
186+
},
187+
"400": {
188+
"description": "The query string is invalid or the request body is missing or malformed.",
189+
"content": {
190+
"application/vnd.api+json": {
191+
"schema": {
192+
"$ref": "#/components/schemas/errorResponseDocument"
193+
}
194+
}
195+
}
196+
},
197+
"404": {
198+
"description": "The fingerprint or a related resource does not exist.",
199+
"content": {
200+
"application/vnd.api+json": {
201+
"schema": {
202+
"$ref": "#/components/schemas/errorResponseDocument"
203+
}
204+
}
205+
}
206+
},
207+
"409": {
208+
"description": "A resource type or identifier in the request body is incompatible.",
209+
"content": {
210+
"application/vnd.api+json": {
211+
"schema": {
212+
"$ref": "#/components/schemas/errorResponseDocument"
213+
}
214+
}
215+
}
216+
},
217+
"422": {
218+
"description": "Validation of the request body failed.",
219+
"content": {
220+
"application/vnd.api+json": {
221+
"schema": {
222+
"$ref": "#/components/schemas/errorResponseDocument"
223+
}
224+
}
225+
}
226+
}
227+
}
228+
}
126229
}
127230
},
128231
"components": {
@@ -272,6 +375,79 @@
272375
},
273376
"additionalProperties": false
274377
},
378+
"fingerprintAttributesInPatchRequest": {
379+
"type": "object",
380+
"properties": {
381+
"firstName": {
382+
"type": "string",
383+
"nullable": true
384+
},
385+
"lastName": {
386+
"minLength": 1,
387+
"type": "string"
388+
},
389+
"userName": {
390+
"maxLength": 18,
391+
"minLength": 3,
392+
"pattern": "^[a-zA-Z]+$",
393+
"type": "string",
394+
"nullable": true
395+
},
396+
"creditCard": {
397+
"type": "string",
398+
"format": "credit-card",
399+
"nullable": true
400+
},
401+
"email": {
402+
"type": "string",
403+
"format": "email",
404+
"nullable": true
405+
},
406+
"phone": {
407+
"type": "string",
408+
"format": "tel",
409+
"nullable": true
410+
},
411+
"age": {
412+
"maximum": 123,
413+
"minimum": 0,
414+
"type": "integer",
415+
"format": "int32",
416+
"nullable": true
417+
},
418+
"profilePicture": {
419+
"type": "string",
420+
"format": "uri",
421+
"nullable": true
422+
},
423+
"backgroundPicture": {
424+
"type": "string",
425+
"format": "uri",
426+
"nullable": true
427+
},
428+
"nextRevalidation": {
429+
"type": "string",
430+
"format": "date-span",
431+
"nullable": true
432+
},
433+
"validatedAt": {
434+
"type": "string",
435+
"format": "date-time",
436+
"nullable": true
437+
},
438+
"validatedDateAt": {
439+
"type": "string",
440+
"format": "date",
441+
"nullable": true
442+
},
443+
"validatedTimeAt": {
444+
"type": "string",
445+
"format": "time",
446+
"nullable": true
447+
}
448+
},
449+
"additionalProperties": false
450+
},
275451
"fingerprintAttributesInPostRequest": {
276452
"required": [
277453
"lastName"
@@ -421,6 +597,30 @@
421597
},
422598
"additionalProperties": false
423599
},
600+
"fingerprintDataInPatchRequest": {
601+
"required": [
602+
"id",
603+
"type"
604+
],
605+
"type": "object",
606+
"properties": {
607+
"type": {
608+
"$ref": "#/components/schemas/fingerprintResourceType"
609+
},
610+
"id": {
611+
"minLength": 1,
612+
"type": "string"
613+
},
614+
"attributes": {
615+
"allOf": [
616+
{
617+
"$ref": "#/components/schemas/fingerprintAttributesInPatchRequest"
618+
}
619+
]
620+
}
621+
},
622+
"additionalProperties": false
623+
},
424624
"fingerprintDataInPostRequest": {
425625
"required": [
426626
"type"
@@ -475,6 +675,22 @@
475675
],
476676
"additionalProperties": false
477677
},
678+
"fingerprintPatchRequestDocument": {
679+
"required": [
680+
"data"
681+
],
682+
"type": "object",
683+
"properties": {
684+
"data": {
685+
"allOf": [
686+
{
687+
"$ref": "#/components/schemas/fingerprintDataInPatchRequest"
688+
}
689+
]
690+
}
691+
},
692+
"additionalProperties": false
693+
},
478694
"fingerprintPostRequestDocument": {
479695
"required": [
480696
"data"

test/OpenApiTests/ModelValidation/ModelValidationTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ public async Task TimeSpan_range_annotation_on_resource_property_produces_expect
191191
// Assert
192192
document.Should().ContainPath($"components.schemas.{modelName}.properties.nextRevalidation").With(nextRevalidationEl =>
193193
{
194-
// TODO: TimeSpan format is an akward object with all the TimeSpan public properties.
194+
nextRevalidationEl.Should().HaveProperty("type", "string");
195+
nextRevalidationEl.Should().HaveProperty("format", "date-span");
195196
nextRevalidationEl.Should().HaveProperty("nullable", true);
196197
});
197198
}

0 commit comments

Comments
 (0)