mirror of
https://github.com/jlengrand/openapi-generator.git
synced 2026-05-16 00:21:19 +00:00
NancyFx:
- Using NodaTime for date types
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
package io.swagger.codegen.languages;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import io.swagger.codegen.CodegenOperation;
|
||||
import io.swagger.codegen.CodegenProperty;
|
||||
import io.swagger.codegen.CodegenType;
|
||||
import io.swagger.codegen.SupportingFile;
|
||||
import io.swagger.models.properties.Property;
|
||||
import io.swagger.models.properties.StringProperty;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
import static io.swagger.codegen.CodegenConstants.*;
|
||||
import static io.swagger.codegen.CodegenType.SERVER;
|
||||
@@ -42,6 +46,7 @@ public class NancyFXServerCodegen extends AbstractCSharpCodegen {
|
||||
addSwitch(USE_DATETIME_OFFSET, USE_DATETIME_OFFSET_DESC, useDateTimeOffsetFlag);
|
||||
addSwitch(USE_COLLECTION, USE_COLLECTION_DESC, useCollection);
|
||||
addSwitch(RETURN_ICOLLECTION, RETURN_ICOLLECTION_DESC, returnICollection);
|
||||
typeMapping.putAll(nodaTimeTypesMappings());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -138,4 +143,19 @@ public class NancyFXServerCodegen extends AbstractCSharpCodegen {
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
return sanitizeName(camelize(property.name)) ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSwaggerType(Property property) {
|
||||
if (property instanceof StringProperty && "time".equalsIgnoreCase(property.getFormat())) {
|
||||
return "time";
|
||||
}
|
||||
return super.getSwaggerType(property);
|
||||
}
|
||||
|
||||
private static Map<String, String> nodaTimeTypesMappings() {
|
||||
return ImmutableMap.of(
|
||||
"time", "LocalTime?",
|
||||
"date", "ZonedDateTime?",
|
||||
"datetime", "ZonedDateTime?");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user