Skip to content

Commit 5855b47

Browse files
simo9000wing328
authored andcommitted
nancyfx basePath => modulePath toggle (#4053)
* fix NancyFX string parser parser needs to access the Value parameter to enable the direct cast at line 102 when handling string parameters * Updated nancyfx sample * Added switch to config to toggle use of yaml base path as module paths
1 parent 92c474b commit 5855b47

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/NancyFXServerCodegen.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public class NancyFXServerCodegen extends AbstractCSharpCodegen {
5555
private static final String API_NAMESPACE = "Modules";
5656
private static final String MODEL_NAMESPACE = "Models";
5757
private static final String IMMUTABLE_OPTION = "immutable";
58+
private static final String USE_BASE_PATH = "writeModulePath";
5859

5960
private static final Map<String, Predicate<Property>> propertyToSwaggerTypeMapping =
6061
createPropertyToSwaggerTypeMapping();
@@ -89,6 +90,7 @@ public NancyFXServerCodegen() {
8990
addSwitch(USE_COLLECTION, USE_COLLECTION_DESC, useCollection);
9091
addSwitch(RETURN_ICOLLECTION, RETURN_ICOLLECTION_DESC, returnICollection);
9192
addSwitch(IMMUTABLE_OPTION, "Enabled by default. If disabled generates model classes with setters", true);
93+
addSwitch(USE_BASE_PATH, "Enabled by default. If disabled, module paths will not mirror api base path", true);
9294
typeMapping.putAll(nodaTimeTypesMappings());
9395
languageSpecificPrimitives.addAll(nodaTimePrimitiveTypes());
9496

@@ -348,7 +350,8 @@ public String toModelName(final String name) {
348350
@Override
349351
public void preprocessSwagger(final Swagger swagger) {
350352
additionalProperties.put("packageContext", sanitizeName(swagger.getBasePath()));
351-
additionalProperties.put("baseContext", swagger.getBasePath());
353+
final Object basePathOption = additionalProperties.get(USE_BASE_PATH);
354+
additionalProperties.put("baseContext", basePathOption == null ? swagger.getBasePath() : "/");
352355
}
353356

354357
@Override

samples/server/petstore/nancyfx/IO.Swagger.sln

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,25 @@ Microsoft Visual Studio Solution File, Format Version 12.00
22
# Visual Studio 2012
33
VisualStudioVersion = 12.0.0.0
44
MinimumVisualStudioVersion = 10.0.0.1
5-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger", "src\IO.Swagger\IO.Swagger.csproj", "{1CE943E7-586D-4D9C-BE8B-3E005FDC39D1}"
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger", "src\IO.Swagger\IO.Swagger.csproj", "{7D50D142-14E1-4E99-842B-18D3AF159948}"
66
EndProject
77
Global
88
GlobalSection(SolutionConfigurationPlatforms) = preSolution
99
Debug|Any CPU = Debug|Any CPU
1010
Release|Any CPU = Release|Any CPU
1111
EndGlobalSection
1212
GlobalSection(ProjectConfigurationPlatforms) = postSolution
13+
<<<<<<< HEAD
14+
{7D50D142-14E1-4E99-842B-18D3AF159948}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{7D50D142-14E1-4E99-842B-18D3AF159948}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{7D50D142-14E1-4E99-842B-18D3AF159948}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{7D50D142-14E1-4E99-842B-18D3AF159948}.Release|Any CPU.Build.0 = Release|Any CPU
18+
=======
1319
{1CE943E7-586D-4D9C-BE8B-3E005FDC39D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1420
{1CE943E7-586D-4D9C-BE8B-3E005FDC39D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
1521
{1CE943E7-586D-4D9C-BE8B-3E005FDC39D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
1622
{1CE943E7-586D-4D9C-BE8B-3E005FDC39D1}.Release|Any CPU.Build.0 = Release|Any CPU
23+
>>>>>>> 92c474b2c235f4635e4be43a97c7941fec64dc82
1724
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1825
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU
1926
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -22,4 +29,4 @@ EndGlobalSection
2229
GlobalSection(SolutionProperties) = preSolution
2330
HideSolutionNode = FALSE
2431
EndGlobalSection
25-
EndGlobal
32+
EndGlobal

samples/server/petstore/nancyfx/src/IO.Swagger/IO.Swagger.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
55
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6-
<ProjectGuid>{1CE943E7-586D-4D9C-BE8B-3E005FDC39D1}</ProjectGuid>
6+
<ProjectGuid>{7D50D142-14E1-4E99-842B-18D3AF159948}</ProjectGuid>
77
<OutputType>Library</OutputType>
88
<AppDesignerFolder>Properties</AppDesignerFolder>
99
<RootNamespace>IO.Swagger.v2</RootNamespace>
@@ -63,4 +63,3 @@
6363
</ItemGroup>
6464
<Import Project="$(MsBuildToolsPath)\Microsoft.CSharp.targets"/>
6565
</Project>
66-

0 commit comments

Comments
 (0)