Skip to content

Commit

Permalink
Merge pull request #435 from Respawnsive/dynamic-query
Browse files Browse the repository at this point in the history
[Query] Dynamic Querystring Parameters implemented
  • Loading branch information
christianhelle authored Aug 3, 2024
2 parents be76c53 + b13015b commit 7b80483
Show file tree
Hide file tree
Showing 32 changed files with 2,874 additions and 452 deletions.
508 changes: 461 additions & 47 deletions README.md

Large diffs are not rendered by default.

95 changes: 49 additions & 46 deletions docs/docfx_project/articles/cli-tool.md

Large diffs are not rendered by default.

405 changes: 405 additions & 0 deletions docs/docfx_project/articles/examples.md

Large diffs are not rendered by default.

20 changes: 13 additions & 7 deletions docs/docfx_project/articles/refitter-file-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ The following is an example `.refitter` file
"generateDefaultAdditionalProperties": true, // Optional. default=true
"operationNameGenerator": "Default", // Optional. May be one of Default, MultipleClientsFromOperationId, MultipleClientsFromPathSegments, MultipleClientsFromFirstTagAndOperationId, MultipleClientsFromFirstTagAndOperationName, MultipleClientsFromFirstTagAndPathSegments, SingleClientFromOperationId, SingleClientFromPathSegments
"immutableRecords": false,
"useDynamicQuerystringParameters": false, // Optional. Default=false
"dependencyInjectionSettings": { // Optional
"baseUrl": "https://petstore3.swagger.io/api/v3", // Optional. Leave this blank to set the base address manually
"httpMessageHandlers": [ // Optional
Expand All @@ -70,13 +71,13 @@ The following is an example `.refitter` file
},
"apizrSettings": { // Optional
"withRequestOptions": true, // Optional. Default=true
"withRegistrationHelper": true, // Optional. Default=false
"withCacheProvider": "InMemory", // Optional. Values=None|Akavache|MonkeyCache|InMemory|DistributedAsString|DistributedAsByteArray. Default=None
"withPriority": true, // Optional. Default=false
"withMediation": true, // Optional. Default=false
"withOptionalMediation": true, // Optional. Default=false
"withMappingProvider": "AutoMapper", // Optional. Values=None|AutoMapper|Mapster. Default=None
"withFileTransfer": true // Optional. Default=false
"withRegistrationHelper": false, // Optional. Default=false
"withCacheProvider": "None", // Optional. Values=None|Akavache|MonkeyCache|InMemory|DistributedAsString|DistributedAsByteArray. Default=None
"withPriority": false, // Optional. Default=false
"withMediation": false, // Optional. Default=false
"withOptionalMediation": false, // Optional. Default=false
"withMappingProvider": "None", // Optional. Values=None|AutoMapper|Mapster. Default=None
"withFileTransfer": false // Optional. Default=false
},
"codeGeneratorSettings": { // Optional. Default settings are the values set in this example
"requiredPropertiesMustBeDefined": true,
Expand Down Expand Up @@ -146,6 +147,7 @@ The following is an example `.refitter` file
- `generateDefaultAdditionalProperties`: Set to `false` to skip default additional properties. Default is `true`
- `operationNameGenerator`: The NSwag `IOperationNameGenerator` implementation to use. See https://refitter.github.io/api/Refitter.Core.OperationNameGeneratorTypes.html
- `immutableRecords`: Set to `true` to generate contracts as immutable records instead of classes. Default is `false`
- `useDynamicQuerystringParameters`: Set to `true` to wrap multiple query parameters into a single complex one. Default is `false` (no wrapping). See /~https://github.com/reactiveui/refit?tab=readme-ov-file#dynamic-querystring-parameters for more information.
- `dependencyInjectionSettings` - Setting this will generated extension methods to `IServiceCollection` for configuring Refit clients
- `baseUrl` - Used as the HttpClient base address. Leave this blank to manually set the base URL
- `httpMessageHandlers` - A collection of `HttpMessageHandler` that is added to the HttpClient pipeline
Expand Down Expand Up @@ -347,6 +349,10 @@ The following is an example `.refitter` file
"type": "boolean",
"description": "Set to true to generate contracts as immutable records instead of classes"
},
"useDynamicQuerystringParameters": {
"type": "boolean",
"description": "Set to true to wrap multiple query parameters into a single complex one."
},
"dependencyInjectionSettings": {
"type": "object",
"properties": {
Expand Down
5 changes: 4 additions & 1 deletion docs/docfx_project/articles/using-the-generated-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ Note that `--use-apizr` uses default Apizr settings with `withRequestOptions` se
In both cases, it will format the generated Refit interfaces to be Apizr ready by:
- Adding a final IApizrRequestOptions options parameter to all generated methods (if `withRequestOptions` is set to `true`)
- Providing cancellation tokens by Apizr request options instead of a dedicated parameter (if `withRequestOptions` is set to `true`)
- Using method overloads instead of optional parameters
- Using method overloads instead of optional parameters (note that setting `useDynamicQuerystringParameters` to true improve overloading experience)

From here, you're definitly free to use the formatted interface with Apizr by registering, configuring and using it following the [Apizr documentation](https://www.apizr.net). But Refitter can go further by generating some helpers to make the configuration easier.

Expand All @@ -271,6 +271,7 @@ This is what the `.refitter` settings file may look like, depending on you confi
{
"openApiPath": "../OpenAPI/v3.0/petstore.json",
"namespace": "Petstore",
"useDynamicQuerystringParameters": true,
"dependencyInjectionSettings": {
"baseUrl": "https://petstore3.swagger.io/api/v3",
"httpMessageHandlers": [ "MyDelegatingHandler" ],
Expand Down Expand Up @@ -328,6 +329,7 @@ This comes in handy especially when generating multiple interfaces, by tag or en
{
"openApiPath": "../OpenAPI/v3.0/petstore.json",
"namespace": "Petstore",
"useDynamicQuerystringParameters": true,
"multipleInterfaces": "ByTag",
"naming": {
"useOpenApiTitle": false,
Expand Down Expand Up @@ -401,6 +403,7 @@ This is what the `.refitter` settings file may look like, depending on you confi
{
"openApiPath": "../OpenAPI/v3.0/petstore.json",
"namespace": "Petstore",
"useDynamicQuerystringParameters": true,
"apizrSettings": {
"withRequestOptions": true, // Recommended to include an Apizr request options parameter to Refit interface methods
"withRegistrationHelper": true, // Mandatory to actually generate the Apizr registration extended method
Expand Down
Loading

0 comments on commit 7b80483

Please sign in to comment.