-
-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for using .refitter file from CLI #127
Merged
Merged
Conversation
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
A new attribute has been added to the Settings.cs file to allow the use of a .refitter settings file. The attribute is named SettingsFilePath and if it's specified, it will ignore all other settings. This provides more control for users who wish to utilize a predefined settings file.
In order to provide an option for users to adjust tool settings through a JSON file, added a process of JSON deserialization. If a settings file path is provided, the tool now reads the file, deserialize the JSON content into the `RefitGeneratorSettings` object, and updates the `OpenApiPath`. This gives users more flexibility to manage their tool configurations.
The configuration in the main program has been extended to include a local example of an openapi refitter. Now, it can process a local openapi.json file using specified refitter settings. This enhancement aims to make it easier for developers to test and debug the API refitting process in their local environment. The source path and settings files' parameters are adjustable depending on developer's configuration.
The change adds an extra option "ByEndpoint" to the configuration in the 'Refitter' application. This new option will allow users to generate multiple interfaces based on different endpoints. It extends the functionality of the "--multiple-interfaces" option and provides more granular control over interface generation from OpenAPI specification.
Added description of the new "--settings-file" option to the examples and options sections of the README file. This change reflects the addition of a new feature which allows users to specify a settings file, ignoring all other settings if specified. This feature increases flexibility and eases configuration under certain conditions.
Codecov Report
@@ Coverage Diff @@
## main #127 +/- ##
=======================================
Coverage 98.29% 98.29%
=======================================
Files 32 32
Lines 997 997
=======================================
Hits 980 980
Misses 6 6
Partials 11 11
Flags with carried forward coverage won't be shown. Click here to find out more. |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This resolves #121
The changes here introduces using the
.refitter
file as a settings file directly from the CLI tool. Using a settings file ignores all other CLI argumentUsage
CLI tool help text
Settings file format
The following is an example
.refitter
fileopenApiPath
- points to the OpenAPI Specifications file. This can be the path to a file stored on disk, relative to the.refitter
file. This can also be a URL to a remote file that will be downloaded over HTTP/HTTPSnamespace
- the namespace used in the generated code. If not specified, this defaults toGeneratedCode
naming.useOpenApiTitle
- a boolean indicating whether the OpenApi title should be used. Default istrue
naming.interfaceName
- the name of the generated interface. The generated code will automatically prefix this withI
so if this set toMyApiClient
then the generated interface is calledIMyApiClient
. Default isApiClient
generateContracts
- a boolean indicating whether contracts should be generated. A use case for this is several API clients use the same contracts. Default istrue
generateXmlDocCodeComments
- a boolean indicating whether XML doc comments should be generated. Default istrue
addAutoGeneratedHeader
- a boolean indicating whether XML doc comments should be generated. Default istrue
addAcceptHeaders
- a boolean indicating whether to add accept headers [Headers("Accept: application/json")]. Default istrue
returnIApiResponse
- a boolean indicating whether to returnIApiResponse<T>
objects. Default isfalse
generateOperationHeaders
- a boolean indicating whether to use operation headers in the generated methods. Default istrue
typeAccessibility
- the generated type accessibility. Possible values arePublic
andInternal
. Default isPublic
useCancellationTokens
- Use cancellation tokens in the generated methods. Default isfalse
useIsoDateFormat
- Set totrue
to explicitly format date query string parameters in ISO 8601 standard date format using delimiters (for example: 2023-06-15). Default isfalse
multipleInterfaces
- Set toByEndpoint
to generate an interface for each endpoint, orByTag
to group Endpoints by their Tag (like SwaggerUI groups them).additionalNamespaces
- A collection of additional namespaces to include in the generated file. A use case for this is when you want to reuse contracts from a different namespace than the generated code. Default is empty