Skip to content

Commit

Permalink
Fixed for loading of files
Browse files Browse the repository at this point in the history
  • Loading branch information
rmaclean committed Jan 28, 2016
1 parent 9e830f0 commit 27d5245
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions nSwagger/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public Configuration()

public bool DoNotWriteTargetFile { get; set; }

[JsonIgnore]
public string HTTPCSPath { get; set; }

public TimeSpan HTTPTimeout { get; set; } = TimeSpan.FromSeconds(30);
Expand All @@ -53,10 +54,10 @@ public static Configuration LoadFromFile(string fileName)
return null;
}

var folder = Path.GetFullPath(fileName);
var folder = Path.GetDirectoryName(fileName);
var settings = File.ReadAllText(fileName);
var result = JsonConvert.DeserializeObject<Configuration>(settings);
result.Target = folder + Path.GetFileName(result.Target);
result.Target = Path.Combine(folder, result.Target);
return result;
}
}
Expand Down
8 changes: 5 additions & 3 deletions nSwagger/Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static async Task Run(Configuration config)
{
Validation(config);
var specifications = await GetSpecifications(config);
var targetPath = Path.GetFullPath(config.Target);
var targetPath = Path.GetDirectoryName(config.Target);
if (!Directory.Exists(targetPath))
{
Directory.CreateDirectory(targetPath);
Expand Down Expand Up @@ -56,15 +56,17 @@ private static async Task<Specification[]> GetSpecifications(Configuration confi

if (config.SaveSettings)
{
config.Target = Path.GetFileName(config.Target);
var originalTarget = config.Target;
config.Target = Path.GetFileName(originalTarget);
var serialisedSettings = JsonConvert.SerializeObject(config);
var settingsFile = config.Target + ".nSwagger";
var settingsFile = originalTarget + ".nSwagger";
if (File.Exists(settingsFile))
{
File.Delete(settingsFile);
}

File.WriteAllText(settingsFile, serialisedSettings);
config.Target = originalTarget;
}

return result.ToArray();
Expand Down

0 comments on commit 27d5245

Please sign in to comment.