forked from loafle/openapi-generator-original
beta release of dukescript generator
This commit is contained in:
parent
774013c7e1
commit
eb627dedfd
32
bin/dukescript-petstore.sh
Normal file
32
bin/dukescript-petstore.sh
Normal file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/dukescript -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dukescript -o samples/client/petstore/dukescript $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
10
bin/windows/dukescript-petstore.bat
Normal file
10
bin/windows/dukescript-petstore.bat
Normal file
@ -0,0 +1,10 @@
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g dukescript -o samples\client\petstore\dukescript
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import org.openapitools.codegen.*;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class DukeScriptClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected String sourceFolder = "src";
|
||||
protected String apiVersion = "1.0.0";
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "dukescript";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates a DukeScript @Model client library (beta).";
|
||||
}
|
||||
|
||||
public DukeScriptClientCodegen() {
|
||||
super();
|
||||
outputFolder = "generated-code/dukescript";
|
||||
modelTemplateFiles.put(
|
||||
"model.mustache",
|
||||
"VMD.java");
|
||||
apiTemplateFiles.put(
|
||||
"api.mustache",
|
||||
"Connector.java");
|
||||
templateDir = "dukescript";
|
||||
apiPackage = "org.openapitools.client.api";
|
||||
modelPackage = "org.openapitools.client.model";
|
||||
additionalProperties.put("apiVersion", apiVersion);
|
||||
typeMapping.put("string", "String");
|
||||
typeMapping.put("integer", "int");
|
||||
typeMapping.put("long", "long");
|
||||
typeMapping.put("short", "short");
|
||||
typeMapping.put("short", "short");
|
||||
typeMapping.put("Boolean", "boolean");
|
||||
typeMapping.put("boolean", "boolean");
|
||||
typeMapping.put("Date", "long");
|
||||
typeMapping.put("DateTime", "long");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
return "_" + name; // add an underscore to the name
|
||||
}
|
||||
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchemaType(Schema p) {
|
||||
String openAPIType = super.getSchemaType(p);
|
||||
String type = null;
|
||||
if (typeMapping.containsKey(openAPIType)) {
|
||||
type = typeMapping.get(openAPIType);
|
||||
if (languageSpecificPrimitives.contains(type)) {
|
||||
return type;
|
||||
}
|
||||
} else {
|
||||
type = openAPIType;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeUnsafeCharacters(String input) {
|
||||
return input.replace("*/", "*_/").replace("/*", "/_*");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeQuotationMark(String input) {
|
||||
// remove " to avoid code injection
|
||||
return input.replace("\"", "");
|
||||
}
|
||||
|
||||
}
|
@ -20,6 +20,7 @@ org.openapitools.codegen.languages.CSharpDotNet2ClientCodegen
|
||||
org.openapitools.codegen.languages.CSharpNancyFXServerCodegen
|
||||
org.openapitools.codegen.languages.DartClientCodegen
|
||||
org.openapitools.codegen.languages.DartJaguarClientCodegen
|
||||
org.openapitools.codegen.languages.DukeScriptClientCodegen
|
||||
org.openapitools.codegen.languages.EiffelClientCodegen
|
||||
org.openapitools.codegen.languages.ElixirClientCodegen
|
||||
org.openapitools.codegen.languages.ElmClientCodegen
|
||||
|
@ -0,0 +1,26 @@
|
||||
package {{package}};
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import {{modelPackage}}.*;
|
||||
import net.java.html.json.Model;
|
||||
import net.java.html.json.ModelOperation;
|
||||
import net.java.html.json.OnReceive;
|
||||
import net.java.html.json.Property;
|
||||
|
||||
{{#operations}}
|
||||
@ModelOperation
|
||||
@Model(className = "{{classname}}", targetId = "", properties = {
|
||||
@Property(name="url", type=String.class )
|
||||
})
|
||||
public class {{classname}}Connector {
|
||||
{{#operation}} // {{summary}}
|
||||
@OnReceive(method = "{{httpMethod}}", {{#allParams}}{{#isBodyParam}}data={{dataType}}.class, {{/isBodyParam}}{{/allParams}} url = "{url}{{path}}")
|
||||
public static void {{operationId}}( {{classname}} model{{#bodyParam}}{{#isBodyParam}}, {{dataType}} {{paramName}}{{/isBodyParam}}{{/bodyParam}}{{#hasProduces}},{{#isListContainer}}List<{{returnBaseType}}> result{{/isListContainer}}{{^isListContainer}} {{baseName}} result{{/isListContainer}},Consumer<{{#isListContainer}}List<{{returnBaseType}}>{{/isListContainer}}{{^isListContainer}} {{baseName}}{{/isListContainer}}> onSuccess{{/hasProduces}}, Consumer<Throwable> onError) {
|
||||
|
||||
}
|
||||
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package {{package}};
|
||||
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
import java.util.List;
|
||||
import net.java.html.json.ComputedProperty;
|
||||
import net.java.html.json.Function;
|
||||
import net.java.html.json.Model;
|
||||
import net.java.html.json.ModelOperation;
|
||||
import net.java.html.json.OnPropertyChange;
|
||||
import net.java.html.json.OnReceive;
|
||||
import net.java.html.json.Property;
|
||||
|
||||
@Model(className = "{{classname}}", targetId = "", properties = {
|
||||
{{#vars}}
|
||||
{{^-first}}, {{/-first}}{{^isListContainer}}@Property(name = "{{baseName}}", type = {{baseType}}.class){{/isListContainer}}{{#isListContainer}}@Property(name = "{{baseName}}", type = {{#items}}{{datatype}}{{/items}}.class, array=true){{/isListContainer}}
|
||||
{{/vars}}
|
||||
}
|
||||
)
|
||||
public class {{classname}}VMD{
|
||||
|
||||
}
|
||||
{{/model}}
|
||||
{{/models}}
|
23
samples/client/petstore/dukescript/.openapi-generator-ignore
Normal file
23
samples/client/petstore/dukescript/.openapi-generator-ignore
Normal file
@ -0,0 +1,23 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
@ -0,0 +1 @@
|
||||
4.0.0-SNAPSHOT
|
@ -0,0 +1,65 @@
|
||||
package org.openapitools.client.api;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.openapitools.client.model.*;
|
||||
import net.java.html.json.Model;
|
||||
import net.java.html.json.ModelOperation;
|
||||
import net.java.html.json.OnReceive;
|
||||
import net.java.html.json.Property;
|
||||
|
||||
@ModelOperation
|
||||
@Model(className = "PetApi", targetId = "", properties = {
|
||||
@Property(name="url", type=String.class )
|
||||
})
|
||||
public class PetApiConnector {
|
||||
// Add a new pet to the store
|
||||
@OnReceive(method = "POST", data=Pet.class, url = "{url}/pet")
|
||||
public static void addPet( PetApi model, Pet pet, Consumer<Throwable> onError) {
|
||||
|
||||
}
|
||||
|
||||
// Deletes a pet
|
||||
@OnReceive(method = "DELETE", url = "{url}/pet/{petId}")
|
||||
public static void deletePet( PetApi model, Consumer<Throwable> onError) {
|
||||
|
||||
}
|
||||
|
||||
// Finds Pets by status
|
||||
@OnReceive(method = "GET", url = "{url}/pet/findByStatus")
|
||||
public static void findPetsByStatus( PetApi model,List<Pet> result,Consumer<List<Pet>> onSuccess, Consumer<Throwable> onError) {
|
||||
|
||||
}
|
||||
|
||||
// Finds Pets by tags
|
||||
@OnReceive(method = "GET", url = "{url}/pet/findByTags")
|
||||
public static void findPetsByTags( PetApi model,List<Pet> result,Consumer<List<Pet>> onSuccess, Consumer<Throwable> onError) {
|
||||
|
||||
}
|
||||
|
||||
// Find pet by ID
|
||||
@OnReceive(method = "GET", url = "{url}/pet/{petId}")
|
||||
public static void getPetById( PetApi model, Pet result,Consumer< Pet> onSuccess, Consumer<Throwable> onError) {
|
||||
|
||||
}
|
||||
|
||||
// Update an existing pet
|
||||
@OnReceive(method = "PUT", data=Pet.class, url = "{url}/pet")
|
||||
public static void updatePet( PetApi model, Pet pet, Consumer<Throwable> onError) {
|
||||
|
||||
}
|
||||
|
||||
// Updates a pet in the store with form data
|
||||
@OnReceive(method = "POST", url = "{url}/pet/{petId}")
|
||||
public static void updatePetWithForm( PetApi model, Consumer<Throwable> onError) {
|
||||
|
||||
}
|
||||
|
||||
// uploads an image
|
||||
@OnReceive(method = "POST", url = "{url}/pet/{petId}/uploadImage")
|
||||
public static void uploadFile( PetApi model, Pet result,Consumer< Pet> onSuccess, Consumer<Throwable> onError) {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package org.openapitools.client.api;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.openapitools.client.model.*;
|
||||
import net.java.html.json.Model;
|
||||
import net.java.html.json.ModelOperation;
|
||||
import net.java.html.json.OnReceive;
|
||||
import net.java.html.json.Property;
|
||||
|
||||
@ModelOperation
|
||||
@Model(className = "StoreApi", targetId = "", properties = {
|
||||
@Property(name="url", type=String.class )
|
||||
})
|
||||
public class StoreApiConnector {
|
||||
// Delete purchase order by ID
|
||||
@OnReceive(method = "DELETE", url = "{url}/store/order/{orderId}")
|
||||
public static void deleteOrder( StoreApi model, Consumer<Throwable> onError) {
|
||||
|
||||
}
|
||||
|
||||
// Returns pet inventories by status
|
||||
@OnReceive(method = "GET", url = "{url}/store/inventory")
|
||||
public static void getInventory( StoreApi model, Store result,Consumer< Store> onSuccess, Consumer<Throwable> onError) {
|
||||
|
||||
}
|
||||
|
||||
// Find purchase order by ID
|
||||
@OnReceive(method = "GET", url = "{url}/store/order/{orderId}")
|
||||
public static void getOrderById( StoreApi model, Store result,Consumer< Store> onSuccess, Consumer<Throwable> onError) {
|
||||
|
||||
}
|
||||
|
||||
// Place an order for a pet
|
||||
@OnReceive(method = "POST", data=Order.class, url = "{url}/store/order")
|
||||
public static void placeOrder( StoreApi model, Order order, Store result,Consumer< Store> onSuccess, Consumer<Throwable> onError) {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package org.openapitools.client.api;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.openapitools.client.model.*;
|
||||
import net.java.html.json.Model;
|
||||
import net.java.html.json.ModelOperation;
|
||||
import net.java.html.json.OnReceive;
|
||||
import net.java.html.json.Property;
|
||||
|
||||
@ModelOperation
|
||||
@Model(className = "UserApi", targetId = "", properties = {
|
||||
@Property(name="url", type=String.class )
|
||||
})
|
||||
public class UserApiConnector {
|
||||
// Create user
|
||||
@OnReceive(method = "POST", data=User.class, url = "{url}/user")
|
||||
public static void createUser( UserApi model, User user, Consumer<Throwable> onError) {
|
||||
|
||||
}
|
||||
|
||||
// Creates list of users with given input array
|
||||
@OnReceive(method = "POST", data=List.class, url = "{url}/user/createWithArray")
|
||||
public static void createUsersWithArrayInput( UserApi model, List user, Consumer<Throwable> onError) {
|
||||
|
||||
}
|
||||
|
||||
// Creates list of users with given input array
|
||||
@OnReceive(method = "POST", data=List.class, url = "{url}/user/createWithList")
|
||||
public static void createUsersWithListInput( UserApi model, List user, Consumer<Throwable> onError) {
|
||||
|
||||
}
|
||||
|
||||
// Delete user
|
||||
@OnReceive(method = "DELETE", url = "{url}/user/{username}")
|
||||
public static void deleteUser( UserApi model, Consumer<Throwable> onError) {
|
||||
|
||||
}
|
||||
|
||||
// Get user by user name
|
||||
@OnReceive(method = "GET", url = "{url}/user/{username}")
|
||||
public static void getUserByName( UserApi model, User result,Consumer< User> onSuccess, Consumer<Throwable> onError) {
|
||||
|
||||
}
|
||||
|
||||
// Logs user into the system
|
||||
@OnReceive(method = "GET", url = "{url}/user/login")
|
||||
public static void loginUser( UserApi model, User result,Consumer< User> onSuccess, Consumer<Throwable> onError) {
|
||||
|
||||
}
|
||||
|
||||
// Logs out current logged in user session
|
||||
@OnReceive(method = "GET", url = "{url}/user/logout")
|
||||
public static void logoutUser( UserApi model, Consumer<Throwable> onError) {
|
||||
|
||||
}
|
||||
|
||||
// Updated user
|
||||
@OnReceive(method = "PUT", data=User.class, url = "{url}/user/{username}")
|
||||
public static void updateUser( UserApi model, User user, Consumer<Throwable> onError) {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package org.openapitools.client.model;
|
||||
|
||||
import java.util.List;
|
||||
import net.java.html.json.ComputedProperty;
|
||||
import net.java.html.json.Function;
|
||||
import net.java.html.json.Model;
|
||||
import net.java.html.json.ModelOperation;
|
||||
import net.java.html.json.OnPropertyChange;
|
||||
import net.java.html.json.OnReceive;
|
||||
import net.java.html.json.Property;
|
||||
|
||||
@Model(className = "ApiResponse", targetId = "", properties = {
|
||||
@Property(name = "code", type = int.class)
|
||||
, @Property(name = "type", type = String.class)
|
||||
, @Property(name = "message", type = String.class)
|
||||
}
|
||||
)
|
||||
public class ApiResponseVMD{
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package org.openapitools.client.model;
|
||||
|
||||
import java.util.List;
|
||||
import net.java.html.json.ComputedProperty;
|
||||
import net.java.html.json.Function;
|
||||
import net.java.html.json.Model;
|
||||
import net.java.html.json.ModelOperation;
|
||||
import net.java.html.json.OnPropertyChange;
|
||||
import net.java.html.json.OnReceive;
|
||||
import net.java.html.json.Property;
|
||||
|
||||
@Model(className = "Category", targetId = "", properties = {
|
||||
@Property(name = "id", type = long.class)
|
||||
, @Property(name = "name", type = String.class)
|
||||
}
|
||||
)
|
||||
public class CategoryVMD{
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package org.openapitools.client.model;
|
||||
|
||||
import java.util.List;
|
||||
import net.java.html.json.ComputedProperty;
|
||||
import net.java.html.json.Function;
|
||||
import net.java.html.json.Model;
|
||||
import net.java.html.json.ModelOperation;
|
||||
import net.java.html.json.OnPropertyChange;
|
||||
import net.java.html.json.OnReceive;
|
||||
import net.java.html.json.Property;
|
||||
|
||||
@Model(className = "Order", targetId = "", properties = {
|
||||
@Property(name = "id", type = long.class)
|
||||
, @Property(name = "petId", type = long.class)
|
||||
, @Property(name = "quantity", type = int.class)
|
||||
, @Property(name = "shipDate", type = long.class)
|
||||
, @Property(name = "status", type = String.class)
|
||||
, @Property(name = "complete", type = boolean.class)
|
||||
}
|
||||
)
|
||||
public class OrderVMD{
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package org.openapitools.client.model;
|
||||
|
||||
import java.util.List;
|
||||
import net.java.html.json.ComputedProperty;
|
||||
import net.java.html.json.Function;
|
||||
import net.java.html.json.Model;
|
||||
import net.java.html.json.ModelOperation;
|
||||
import net.java.html.json.OnPropertyChange;
|
||||
import net.java.html.json.OnReceive;
|
||||
import net.java.html.json.Property;
|
||||
|
||||
@Model(className = "Pet", targetId = "", properties = {
|
||||
@Property(name = "id", type = long.class)
|
||||
, @Property(name = "category", type = Category.class)
|
||||
, @Property(name = "name", type = String.class)
|
||||
, @Property(name = "photoUrls", type = String.class, array=true)
|
||||
, @Property(name = "tags", type = Tag.class, array=true)
|
||||
, @Property(name = "status", type = String.class)
|
||||
}
|
||||
)
|
||||
public class PetVMD{
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package org.openapitools.client.model;
|
||||
|
||||
import java.util.List;
|
||||
import net.java.html.json.ComputedProperty;
|
||||
import net.java.html.json.Function;
|
||||
import net.java.html.json.Model;
|
||||
import net.java.html.json.ModelOperation;
|
||||
import net.java.html.json.OnPropertyChange;
|
||||
import net.java.html.json.OnReceive;
|
||||
import net.java.html.json.Property;
|
||||
|
||||
@Model(className = "Tag", targetId = "", properties = {
|
||||
@Property(name = "id", type = long.class)
|
||||
, @Property(name = "name", type = String.class)
|
||||
}
|
||||
)
|
||||
public class TagVMD{
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package org.openapitools.client.model;
|
||||
|
||||
import java.util.List;
|
||||
import net.java.html.json.ComputedProperty;
|
||||
import net.java.html.json.Function;
|
||||
import net.java.html.json.Model;
|
||||
import net.java.html.json.ModelOperation;
|
||||
import net.java.html.json.OnPropertyChange;
|
||||
import net.java.html.json.OnReceive;
|
||||
import net.java.html.json.Property;
|
||||
|
||||
@Model(className = "User", targetId = "", properties = {
|
||||
@Property(name = "id", type = long.class)
|
||||
, @Property(name = "username", type = String.class)
|
||||
, @Property(name = "firstName", type = String.class)
|
||||
, @Property(name = "lastName", type = String.class)
|
||||
, @Property(name = "email", type = String.class)
|
||||
, @Property(name = "password", type = String.class)
|
||||
, @Property(name = "phone", type = String.class)
|
||||
, @Property(name = "userStatus", type = int.class)
|
||||
}
|
||||
)
|
||||
public class UserVMD{
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user