Closed dammitjanet closed 2 months ago
@dammitjanet Thanks for taking the time to report this
I'll implement the fix here as it's a trivial fix.
The Serializer
class in Refitter.Core has no internal functional purpose, I mostly used it for testing
Is your feature request related to a problem? Please describe. The .refitter file generated by the new functionality in #879 works well, however the refitter file itself is generated without any formatting (minified) so, it's a little unreadable without reformatting (prettified).
Describe the solution you'd like The refitter file to be generated as a human readable json with indentation, etc
Describe alternatives you've considered none
Additional context I notice the json serializer in use within RefitterCodeGenerator is the one inside Refitter (Refitter.Core.Serializer), so it would need either changes to both Refitter and the Api Client Code gen to resolve
As to not break refitter, I'd probably update the Serializer methods to take an optional JsonSerializerOptions parameter to use over and above the one defined as private static
so you'd define the JsonSerializerOptions in RefitterCodeGenerator as
private static readonly JsonSerializerOptions JsonSerializerOptions = new() { PropertyNameCaseInsensitive = true, PropertyNamingPolicy = JsonNamingPolicy.CamelCase, WriteIndented = true, };
then use those serialiser setting when writing the file as so:
var json = Serializer.Serialize(settings, JsonSerializerOptions); var json = Serializer.Serialize(settings); File.WriteAllText( Path.Combine( fileInfo.Directory.FullName, fileInfo.Name.Replace(fileInfo.Extension, ".refitter")), json);