Versioning of generated model (namespace, base context).

This commit is contained in:
Marcin Stefaniuk 2016-05-25 11:23:11 +02:00
parent bf68801295
commit c59f2b0322
5 changed files with 14 additions and 8 deletions

View File

@ -5,6 +5,7 @@ import io.swagger.codegen.CodegenOperation;
import io.swagger.codegen.CodegenProperty;
import io.swagger.codegen.CodegenType;
import io.swagger.codegen.SupportingFile;
import io.swagger.models.Swagger;
import io.swagger.models.properties.Property;
import io.swagger.models.properties.StringProperty;
import org.slf4j.Logger;
@ -144,6 +145,12 @@ public class NancyFXServerCodegen extends AbstractCSharpCodegen {
return super.toApiFilename(name) + "Module";
}
@Override
public void preprocessSwagger(Swagger swagger) {
additionalProperties.put("packageContext", sanitizeName(swagger.getBasePath()));
additionalProperties.put("baseContext", swagger.getBasePath());
}
@Override
public String toEnumName(CodegenProperty property) {
return sanitizeName(camelize(property.name)) ;

View File

@ -6,7 +6,7 @@
<ProjectGuid>{{packageGuid}}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>{{packageName}}</RootNamespace>
<RootNamespace>{{packageName}}.{{packageContext}}</RootNamespace>
<AssemblyName>{{packageTitle}}</AssemblyName>
{{^supportsUWP}}
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>

View File

@ -3,17 +3,17 @@ using Nancy;
using Nancy.ModelBinding;
using System.Collections.Generic;
using Sharpility.Base;
using {{packageName}}.Models;
using {{packageName}}.Utils;
using {{packageName}}.{{packageContext}}.Models;
using {{packageName}}.{{packageContext}}.Utils;
using NodaTime;
namespace {{packageName}}.Modules
namespace {{packageName}}.{{packageContext}}.Modules
{ {{#operations}}{{#operation}}{{#allParams}}{{#isEnum}}
{{>innerApiEnum}}{{/isEnum}}{{/allParams}}{{/operation}}
public partial class {{classname}}Module : NancyModule
{
public {{classname}}Module({{classname}}Service service) : base("")
public {{classname}}Module({{classname}}Service service) : base("{{baseContext}}")
{ {{#operation}}
{{httpMethod}}["{{path}}"] = parameters =>
{

View File

@ -7,7 +7,7 @@ using NodaTime;
{{#models}}
{{#model}}
namespace {{packageName}}.Models
namespace {{packageName}}.{{packageContext}}.Models
{ {{#vars}}{{#isEnum}}
{{>innerModelEnum}}{{/isEnum}}{{#items.isEnum}}
{{#items}}{{>innerModelEnum}}{{/items}}{{/items.isEnum}}{{/vars}}

View File

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
@ -8,7 +7,7 @@ using Sharpility.Base;
using Sharpility.Extensions;
using Sharpility.Util;
namespace {{packageName}}.Utils
namespace {{packageName}}.{{packageContext}}.Utils
{
internal static class Parameters
{