Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to OpenAPI Generator #26

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion generators/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ repositories {
}

dependencies {
implementation 'io.swagger.codegen.v3:swagger-codegen-cli:3.0.56'
implementation 'org.openapitools:openapi-generator-cli:7.6.0'
}
Original file line number Diff line number Diff line change
@@ -1,39 +1,32 @@
package io.swagger.codegen.v3.generators.typescript;

package org.openapitools.codegen.languages;

import org.openapitools.codegen.*;
import com.pdc.SemVerUtils;
import io.swagger.codegen.v3.SupportingFile;
import io.swagger.v3.oas.models.OpenAPI;

import java.io.File;

public class TypescriptGenerator extends AbstractTypeScriptClientCodegen {
protected String sourceFolder = "src";
protected String templateVersion = "0.0.1";
protected String packageVersion = "";

/**
* Configures a friendly name for the generator. This will be used by the generator
* to select the library with the -l flag.
*
* @return the friendly name for the generator
*/
public CodegenType getTag() {
return CodegenType.CLIENT;
}

public String getName() {
return "typescript";
}

/**
* Returns human-friendly help for the generator. Provide the consumer with help
* tips, parameters here
*
* @return A string value for the help message
*/
public String getHelp() {
return "Generates a typescript client library.";
}

public TypescriptGenerator() {
super();
outputFolder = "build/typescript";
outputFolder = "build" + File.separator + "typescript";
embeddedTemplateDir = templateDir = "typescript";
modelTemplateFiles.put(
"types/type.mustache",
".ts"
Expand Down Expand Up @@ -65,26 +58,11 @@ public void preprocessOpenAPI(OpenAPI openAPI) {

@Override
public String modelFileFolder() {
return outputFolder + "/" + sourceFolder + "/types/" + modelPackage().replace('.', File.separatorChar);
return outputFolder + File.separator + sourceFolder + File.separator + "types" + File.separator + modelPackage().replace('.', File.separatorChar);
}

@Override
public String apiFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
}

@Override
public String getArgumentsLocation() {
return null;
}

@Override
public String getDefaultTemplateDir() {
return "typescript";
}

@Override
public String getTemplateDir() {
return "typescript";
return outputFolder + File.separator + sourceFolder + File.separator + apiPackage().replace('.', File.separatorChar);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.openapitools.codegen.languages.TypescriptGenerator
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Writable } from './Writable';
{{#model}}
export interface {{classname}} {
{{#vars}}
{{#isReadOnly}}readonly {{/isReadOnly}}{{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}};
{{#isReadOnly}}readonly {{/isReadOnly}}{{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}};
{{/vars}}
}

Expand Down