Skip to content

Commit

Permalink
Fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
verdie-g committed May 27, 2024
1 parent 07c9d7d commit 43bae11
Show file tree
Hide file tree
Showing 3 changed files with 221 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public async Task Out_of_range_integer_should_return_an_error(int age)
}

[Fact]
public async Task Invalid_url_should_return_an_error()
public async Task Invalid_uri_should_return_an_error()
{
// Arrange
Fingerprint fingerprint = _fakers.Fingerprint.Generate();
Expand Down Expand Up @@ -247,7 +247,7 @@ public async Task Invalid_url_should_return_an_error()
}

[Fact]
public async Task Invalid_url_as_string_should_return_an_error()
public async Task Invalid_url_should_return_an_error()
{
// Arrange
Fingerprint fingerprint = _fakers.Fingerprint.Generate();
Expand Down Expand Up @@ -438,7 +438,7 @@ public async Task Fitting_all_the_constraints_should_work()
BackgroundPicture = new Uri(fingerprint.BackgroundPicture!),
NextRevalidation = "02:00:00",
ValidatedAt = fingerprint.ValidatedAt!.Value.ToUniversalTime(),
// TODO: ValidatedDateAt = new DateTimeOffset(fingerprint.ValidatedDateAt!.Value.ToDateTime(new TimeOnly()).ToUniversalTime()),
ValidatedDateAt = new DateTimeOffset(fingerprint.ValidatedDateAt!.Value.ToDateTime(new TimeOnly()).ToUniversalTime()),
ValidatedTimeAt = fingerprint.ValidatedTimeAt!.Value.ToTimeSpan()
}
}
Expand Down
216 changes: 216 additions & 0 deletions test/OpenApiTests/ModelValidation/GeneratedSwagger/swagger.g.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,109 @@
}
}
}
},
"/fingerprints/{id}": {
"patch": {
"tags": [
"fingerprints"
],
"summary": "Updates an existing fingerprint.",
"operationId": "patchFingerprint",
"parameters": [
{
"name": "id",
"in": "path",
"description": "The identifier of the fingerprint to update.",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "query",
"in": "query",
"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.",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string",
"nullable": true
},
"example": ""
}
}
],
"requestBody": {
"description": "The attributes and relationships of the fingerprint to update. Omitted fields are left unchanged.",
"content": {
"application/vnd.api+json": {
"schema": {
"allOf": [
{
"$ref": "#/components/schemas/fingerprintPatchRequestDocument"
}
]
}
}
},
"required": true
},
"responses": {
"200": {
"description": "The fingerprint was successfully updated, which resulted in additional changes. The updated fingerprint is returned.",
"content": {
"application/vnd.api+json": {
"schema": {
"$ref": "#/components/schemas/fingerprintPrimaryResponseDocument"
}
}
}
},
"204": {
"description": "The fingerprint was successfully updated, which did not result in additional changes."
},
"400": {
"description": "The query string is invalid or the request body is missing or malformed.",
"content": {
"application/vnd.api+json": {
"schema": {
"$ref": "#/components/schemas/errorResponseDocument"
}
}
}
},
"404": {
"description": "The fingerprint or a related resource does not exist.",
"content": {
"application/vnd.api+json": {
"schema": {
"$ref": "#/components/schemas/errorResponseDocument"
}
}
}
},
"409": {
"description": "A resource type or identifier in the request body is incompatible.",
"content": {
"application/vnd.api+json": {
"schema": {
"$ref": "#/components/schemas/errorResponseDocument"
}
}
}
},
"422": {
"description": "Validation of the request body failed.",
"content": {
"application/vnd.api+json": {
"schema": {
"$ref": "#/components/schemas/errorResponseDocument"
}
}
}
}
}
}
}
},
"components": {
Expand Down Expand Up @@ -272,6 +375,79 @@
},
"additionalProperties": false
},
"fingerprintAttributesInPatchRequest": {
"type": "object",
"properties": {
"firstName": {
"type": "string",
"nullable": true
},
"lastName": {
"minLength": 1,
"type": "string"
},
"userName": {
"maxLength": 18,
"minLength": 3,
"pattern": "^[a-zA-Z]+$",
"type": "string",
"nullable": true
},
"creditCard": {
"type": "string",
"format": "credit-card",
"nullable": true
},
"email": {
"type": "string",
"format": "email",
"nullable": true
},
"phone": {
"type": "string",
"format": "tel",
"nullable": true
},
"age": {
"maximum": 123,
"minimum": 0,
"type": "integer",
"format": "int32",
"nullable": true
},
"profilePicture": {
"type": "string",
"format": "uri",
"nullable": true
},
"backgroundPicture": {
"type": "string",
"format": "uri",
"nullable": true
},
"nextRevalidation": {
"type": "string",
"format": "date-span",
"nullable": true
},
"validatedAt": {
"type": "string",
"format": "date-time",
"nullable": true
},
"validatedDateAt": {
"type": "string",
"format": "date",
"nullable": true
},
"validatedTimeAt": {
"type": "string",
"format": "time",
"nullable": true
}
},
"additionalProperties": false
},
"fingerprintAttributesInPostRequest": {
"required": [
"lastName"
Expand Down Expand Up @@ -421,6 +597,30 @@
},
"additionalProperties": false
},
"fingerprintDataInPatchRequest": {
"required": [
"id",
"type"
],
"type": "object",
"properties": {
"type": {
"$ref": "#/components/schemas/fingerprintResourceType"
},
"id": {
"minLength": 1,
"type": "string"
},
"attributes": {
"allOf": [
{
"$ref": "#/components/schemas/fingerprintAttributesInPatchRequest"
}
]
}
},
"additionalProperties": false
},
"fingerprintDataInPostRequest": {
"required": [
"type"
Expand Down Expand Up @@ -475,6 +675,22 @@
],
"additionalProperties": false
},
"fingerprintPatchRequestDocument": {
"required": [
"data"
],
"type": "object",
"properties": {
"data": {
"allOf": [
{
"$ref": "#/components/schemas/fingerprintDataInPatchRequest"
}
]
}
},
"additionalProperties": false
},
"fingerprintPostRequestDocument": {
"required": [
"data"
Expand Down
3 changes: 2 additions & 1 deletion test/OpenApiTests/ModelValidation/ModelValidationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ public async Task TimeSpan_range_annotation_on_resource_property_produces_expect
// Assert
document.Should().ContainPath($"components.schemas.{modelName}.properties.nextRevalidation").With(nextRevalidationEl =>
{
// TODO: TimeSpan format is an akward object with all the TimeSpan public properties.
nextRevalidationEl.Should().HaveProperty("type", "string");
nextRevalidationEl.Should().HaveProperty("format", "date-span");
nextRevalidationEl.Should().HaveProperty("nullable", true);
});
}
Expand Down

0 comments on commit 43bae11

Please sign in to comment.