Table of Contents

Class RefitterSettingsLoader

Namespace
Refitter.Core
Assembly
Refitter.Core.dll

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

settingsFilePath string

The path to the settings file.

refitGeneratorSettings RefitGeneratorSettings

The 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

path string

The path to inspect.

Returns

bool

true when the path is an HTTP or HTTPS URL; otherwise false.

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

json string

The raw contents of the .refitter settings file.

baseDirectory string

The 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 json cannot 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

settings RefitGeneratorSettings

The settings whose specification paths should be resolved.

baseDirectory string

The directory to resolve relative paths against.