Skip to content

Commit

Permalink
Merge pull request #9188 from swagger-api/kotlin_server_generation_fix
Browse files Browse the repository at this point in the history
set default library in order to fix issue.
  • Loading branch information
HugoMario authored Feb 18, 2019
2 parents 4a9971d + 7c426de commit 3c4b580
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
import com.samskivert.mustache.Mustache;
import io.swagger.codegen.CliOption;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.CodegenModel;
import io.swagger.codegen.CodegenOperation;
import io.swagger.codegen.CodegenType;
import io.swagger.codegen.SupportingFile;
import io.swagger.codegen.mustache.*;
import io.swagger.models.ArrayModel;
import io.swagger.models.Model;
import io.swagger.models.Operation;
import io.swagger.models.Swagger;
import io.swagger.models.parameters.Parameter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -15,10 +22,14 @@
import java.util.List;
import java.util.Map;

import static io.swagger.codegen.CodegenConstants.GENERATE_APIS;

public class KotlinServerCodegen extends AbstractKotlinCodegen {

public static final String DEFAULT_LIBRARY = Constants.KTOR;
static Logger LOGGER = LoggerFactory.getLogger(KotlinServerCodegen.class);
public static final String GENERATE_APIS = "generateApis";

private static Logger LOGGER = LoggerFactory.getLogger(KotlinServerCodegen.class);
private Boolean autoHeadFeatureEnabled = true;
private Boolean conditionalHeadersFeatureEnabled = false;
private Boolean hstsFeatureEnabled = true;
Expand Down Expand Up @@ -123,8 +134,14 @@ public CodegenType getTag() {
public void processOpts() {
super.processOpts();

if (!additionalProperties.containsKey(GENERATE_APIS)) {
additionalProperties.put(GENERATE_APIS, true);
}

if (additionalProperties.containsKey(CodegenConstants.LIBRARY)) {
this.setLibrary((String) additionalProperties.get(CodegenConstants.LIBRARY));
} else {
this.setLibrary(DEFAULT_LIBRARY);
}

if (additionalProperties.containsKey(Constants.AUTOMATIC_HEAD_REQUESTS)) {
Expand Down Expand Up @@ -157,9 +174,9 @@ public void processOpts() {
additionalProperties.put(Constants.COMPRESSION, getCompressionFeatureEnabled());
}

Boolean generateApis = additionalProperties.containsKey(CodegenConstants.GENERATE_APIS) && (Boolean)additionalProperties.get(CodegenConstants.GENERATE_APIS);
String packageFolder = (sourceFolder + File.separator + packageName).replace(".", File.separator);
String resourcesFolder = "src/main/resources"; // not sure this can be user configurable.
Boolean generateApis = additionalProperties.containsKey(GENERATE_APIS) && (Boolean)additionalProperties.get(GENERATE_APIS);

supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("Dockerfile.mustache", "", "Dockerfile"));
Expand Down

0 comments on commit 3c4b580

Please sign in to comment.