Skip to content

Commit

Permalink
Fixed Issue When Using Dependency Injection
Browse files Browse the repository at this point in the history
  • Loading branch information
jrote1 committed Oct 30, 2013
1 parent c4a2a0f commit 8d9be3d
Show file tree
Hide file tree
Showing 31 changed files with 4,890 additions and 43,639 deletions.
8 changes: 6 additions & 2 deletions ApiDocumentation/CamelCaseContractResolver.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using SwaggerAPIDocumentation.ViewModels;

namespace SwaggerAPIDocumentation
{
internal class CamelCaseContractResolver : DefaultContractResolver
{
protected override string ResolvePropertyName( string propertyName )
{
return char.ToLower(propertyName[0]) + propertyName.Substring( 1 );
return char.ToLower( propertyName[ 0 ] ) + propertyName.Substring( 1 );
}
}
}
3 changes: 2 additions & 1 deletion ApiDocumentation/Implementations/JsonSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public String SerializeObject( Object objectToBeEncoded )
{
return JsonConvert.SerializeObject( objectToBeEncoded, Formatting.Indented, new JsonSerializerSettings
{
ContractResolver = new CamelCaseContractResolver()
ContractResolver = new CamelCaseContractResolver(),

} );
}
}
Expand Down
2 changes: 1 addition & 1 deletion ApiDocumentation/Interfaces/IJsonSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace SwaggerAPIDocumentation.Interfaces
{
internal interface IJsonSerializer
public interface IJsonSerializer
{
String SerializeObject( Object objectToBeEncoded );
}
Expand Down
5 changes: 3 additions & 2 deletions ApiDocumentation/SwaggerAPIDocumentation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.5.0.8\lib\net40\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=3.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.3.5.8\lib\35\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
2 changes: 2 additions & 0 deletions ApiDocumentation/SwaggerApiDocumentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class SwaggerApiDocumentation<TBaseApiControllerType> : ISwaggerApiDocume

public SwaggerApiDocumentation() : this( new SwaggerDocumentationAssemblyTools(), new SwaggerDocumentationCreator(), new JsonSerializer() ) {}

public SwaggerApiDocumentation( IJsonSerializer jsonSerializer ) : this( new SwaggerDocumentationAssemblyTools(), new SwaggerDocumentationCreator(), jsonSerializer ) {}

internal SwaggerApiDocumentation(
ISwaggerDocumentationAssemblyTools swaggerDocumentationAssemblyTools,
ISwaggerDocumentationCreator swaggerDocumentationCreator,
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion ApiDocumentation/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net40" />
<package id="Newtonsoft.Json" version="3.5.8" targetFramework="net40" />
</packages>
Binary file modified SwaggerAPIDocumentation.v11.suo
Binary file not shown.
33 changes: 33 additions & 0 deletions SwaggerAPIDocumentationTests/NewtonSoftTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using SwaggerAPIDocumentation.Implementations;
using SwaggerAPIDocumentation.ViewModels;

namespace SwaggerAPIDocumentationTests
{
[TestFixture]
public class NewtonSoftTests
{
[Test]
public void CanSerializeDictionary()
{
SwaggerApiResource swaggerApiResource = new SwaggerApiResource
{
Models = new Dictionary<String, ApiDocModel>
{
{
"Test", new ApiDocModel()
}
}
};

JsonSerializer jsonSerializer = new JsonSerializer();
var result = jsonSerializer.SerializeObject( swaggerApiResource );
Assert.IsNotNull( result );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<Compile Include="BaseAutomatedMockWireupTest.cs" />
<Compile Include="MockDictionary.cs" />
<Compile Include="ModelsGeneratorTests.cs" />
<Compile Include="NewtonSoftTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SwaggerAPIDocumentationTests.cs" />
<Compile Include="SwaggerDocumentationAssemblyToolsTests.cs" />
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Newtonsoft.Json</id>
<version>5.0.8</version>
<version>3.5.8</version>
<title>Json.NET</title>
<authors>James Newton-King</authors>
<owners>James Newton-King</owners>
<licenseUrl>https://raw.github.com/JamesNK/Newtonsoft.Json/master/LICENSE.md</licenseUrl>
<projectUrl>http://james.newtonking.com/json</projectUrl>
<projectUrl>http://james.newtonking.com/projects/json-net.aspx</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Json.NET is a popular high-performance JSON framework for .NET</description>
<language>en-US</language>
<summary>Json.NET is a popular high-performance JSON framework for .NET</summary>
<tags>json</tags>
</metadata>
</package>
Binary file not shown.
Loading

0 comments on commit 8d9be3d

Please sign in to comment.