-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Rust-Axum] Fix uuid in header params causing compilation errors (#18563
) * fix: Fix uuid in header params causing errors Routes with header parameters with a `format` of `uuid` in the openAPI specification used to cause a compilation error in the resulting Rust Axum code. This commit fixes the issue by including the correct conversion trait implementation on the condition that at least one header parameter of `format` `uuid` is included in the specification. * refactor: Add final to boolean * fix: Bring str::FromStr optionally into scope The trait needs to be in scope for the TryFrom implementation: `TryFrom<HeaderValue> for IntoHeaderValue<uuid::Uuid> ` It will only be brought into scope when the implementation is rendered. * test: Add integration test and its specification This commit adds an integration test that tests the bug fix for #18554. A header parameter of `format: uuid` is included in one route. This makes the example create a route handler that tries to extract a Rust `uuid::Uuid` type from the header. The integration test will check that the generated code compiles. * test: Update examples and run integration test The generated samples are updated with: `./bin/generate-samples.sh ./bin/configs/manual/*.yaml` Most example projects have their version numbers bumped. Some changes show, that there are some other unrelated changes to the files, which indicates that some prior commit did not update the samples accordingly. The relevant integration test `mvn integration-test -f samples/server/petstore/rust-axum/pom.xml` passes.
- Loading branch information
Showing
35 changed files
with
2,760 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
generatorName: rust-axum | ||
outputDir: samples/server/petstore/rust-axum/output/rust-axum-header-uuid | ||
inputSpec: modules/openapi-generator/src/test/resources/3_0/rust-axum/rust-axum-header-uuid.yaml | ||
templateDir: modules/openapi-generator/src/main/resources/rust-axum | ||
generateAliasAsModel: true | ||
additionalProperties: | ||
hideGenerationTimestamp: "true" | ||
packageName: rust-axum-header-uui | ||
enablePostProcessFile: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
modules/openapi-generator/src/test/resources/3_0/rust-axum/rust-axum-header-uuid.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Test deserialization of uuid objects in headers | ||
openapi: 3.0.0 | ||
info: | ||
title: Sample API | ||
version: 0.1.9 | ||
paths: | ||
/users: | ||
post: | ||
description: Adds a user to the users database table. | ||
parameters: | ||
- $ref: "#/components/parameters/UuidHeaderParam" | ||
responses: | ||
"201": # status code | ||
description: Added row to table! | ||
content: | ||
application/json: | ||
schema: | ||
type: string | ||
components: | ||
schemas: | ||
HeaderUuid: | ||
type: string | ||
format: uuid | ||
example: a9f5a638-728c-479d-af9b-016eb8049ab6 | ||
parameters: | ||
UuidHeaderParam: | ||
name: some_uid | ||
in: header | ||
required: true | ||
description: A uuid transmitted in the header. | ||
schema: | ||
$ref: "#/components/schemas/HeaderUuid" |
2 changes: 1 addition & 1 deletion
2
samples/server/petstore/rust-axum/output/multipart-v3/.openapi-generator/VERSION
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
7.5.0-SNAPSHOT | ||
7.6.0-SNAPSHOT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
samples/server/petstore/rust-axum/output/openapi-v3/.openapi-generator/VERSION
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
7.5.0-SNAPSHOT | ||
7.6.0-SNAPSHOT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
samples/server/petstore/rust-axum/output/ops-v3/.openapi-generator/VERSION
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
7.5.0-SNAPSHOT | ||
7.6.0-SNAPSHOT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...st-axum/output/petstore-with-fake-endpoints-models-for-testing/.openapi-generator/VERSION
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
7.5.0-SNAPSHOT | ||
7.6.0-SNAPSHOT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.