Class RefitterSettingsLoader
Loads RefitGeneratorSettings from the contents of a .refitter settings file.
public static class RefitterSettingsLoader
- Inheritance
-
RefitterSettingsLoader
- Inherited Members
Remarks
This module deliberately operates on already-read JSON text plus the directory the settings
file lives in, rather than reading the file itself. File reading stays with each consumer
(the CLI reads from disk; the source generator reads via Roslyn's AdditionalText), which
keeps filesystem APIs out of the analyzer assembly and preserves incremental-generation semantics.
Methods
ApplyDefaults(string, RefitGeneratorSettings)
Applies default values to settings that are not explicitly set in a settings file.
public static void ApplyDefaults(string settingsFilePath, RefitGeneratorSettings refitGeneratorSettings)
Parameters
settingsFilePathstringThe path to the settings file.
refitGeneratorSettingsRefitGeneratorSettingsThe settings to apply defaults to.
IsUrl(string)
Determines whether the specified path is an absolute HTTP or HTTPS URL.
public static bool IsUrl(string path)
Parameters
pathstringThe path to inspect.
Returns
Load(string, string)
Deserializes the contents of a .refitter settings file and resolves any relative
OpenAPI specification paths against the directory the settings file lives in.
public static RefitGeneratorSettings Load(string json, string baseDirectory)
Parameters
jsonstringThe raw contents of the
.refittersettings file.baseDirectorystringThe directory the settings file lives in. Relative OpenApiPath and OpenApiPaths entries are resolved against this directory.
Returns
- RefitGeneratorSettings
The deserialized settings with relative specification paths resolved to absolute paths.
Exceptions
- JsonException
Thrown when
jsoncannot be deserialized.
ResolveRelativeSpecPaths(RefitGeneratorSettings, string)
Resolves any relative OpenAPI specification paths on settings against
baseDirectory. URLs and already-rooted paths are left untouched.
public static void ResolveRelativeSpecPaths(RefitGeneratorSettings settings, string baseDirectory)
Parameters
settingsRefitGeneratorSettingsThe settings whose specification paths should be resolved.
baseDirectorystringThe directory to resolve relative paths against.