-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
NSwag contracts #186
Comments
Yeah, there's a lot of default parameters in CSharpClientGeneratorFactory. |
@bielik01 I actually have this in my backlog. I plan to expose settings to customize the entire CSharpGeneratorSettings You have things like these options that can be customized AnyType = "object";
Namespace = "MyNamespace";
DateType = "System.DateTimeOffset";
DateTimeType = "System.DateTimeOffset";
TimeType = "System.TimeSpan";
TimeSpanType = "System.TimeSpan";
ArrayType = "System.Collections.Generic.ICollection";
ArrayInstanceType = "System.Collections.ObjectModel.Collection";
ArrayBaseType = "System.Collections.ObjectModel.Collection";
DictionaryType = "System.Collections.Generic.IDictionary";
DictionaryInstanceType = "System.Collections.Generic.Dictionary";
DictionaryBaseType = "System.Collections.Generic.Dictionary";
ClassStyle = CSharpClassStyle.Poco;
JsonLibrary = CSharpJsonLibrary.NewtonsoftJson;
RequiredPropertiesMustBeDefined = true;
GenerateDataAnnotations = true;
TypeAccessModifier = "public";
PropertySetterAccessModifier = string.Empty;
GenerateJsonMethods = false;
EnforceFlagEnums = false;
InlineNamedArrays = false;
InlineNamedDictionaries = false;
InlineNamedTuples = true; So the .refitter settings file might look something like: {
"openApiPath": "./OpenAPI/v3.0/petstore.json",
"namespace": "Petstore",
"contractsGeneratorSettings": {
"dateType": "System.DateTime",
"dateTimeType": "System.DateTime",
"arrayType": "System.Collections.Generic.IList"
}
} |
@all-contributors please add @bielik01 for ideas |
I've put up a pull request to add @bielik01! 🎉 |
Is it "contractsGeneratorSettings" or "codeGeneratorSettings"? In the README it's the latter. Also I just confused with "namespace" being mentioned at the top level AND the settings part. The former is valid. |
@alrz In the end, I went with I try to keep the READMEs up-to-date. Recently, I also introduced a documentation site - https://refitter.github.io that I will also try my best to keep up-to-date |
This is a mistake and only the top level Thanks for pointing that out @alrz |
@all-contributors please add @alrz for bugs |
I've put up a pull request to add @alrz! 🎉 |
but that was namespace for contracts, it was perfectly fine there |
@bielik01 Are you interested in having different namespaces for contracts and the interfaces? That's not how its currently implemented and I originally wanted to use the same namespace for all generated types, be it DTO objects or the interface(s), since they are in the same file. Having different namespaces for contracts and interfaces would require importing the contracts namespace into each interface, or specifying the full type name on all usages I have toyed with the idea of splitting the contracts and interfaces into different files, but it's not how I personally use the tool, and I didn't want to assume how others might use it Is there an interest for splitting the output into multiple files? It's not really that hard to implement, and I won't use it myself, but if there are others who need it then why not 😃 |
and #184 is missing to completion 😅 I wonder if it should stay |
Currently, NSwag returns me a string containing all the generated contracts. I can write this to another file if we can introduce a setting that describes it. A lot of the options in
Coming soon :)
I renamed it to |
Not really much left for me to do here so I'll close this issue |
Maybe it's there and I couldn't find it, but when generating contracts, I'd like to specify some NSwag options like dateType (I don't like DateTimeOffset) or arrayType.
The text was updated successfully, but these errors were encountered: