mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-06 02:25:20 +00:00
GraphQL Server (#1603)
* Add GraphQL express/apollo server generator * add basic resolvers; adjust parameters/input types * small adjustments and improvements * adjust logger config for GraphQL generators * remove MaxPermSize form bash script as it will be removed from later Java versions; add isNullable utility helper method; Adjust TODOs for graphql implementation * re-created samples for graphql config and server generators * re-added templates for graphql config generator * add graphql-config-petstore bash script * add isNullable utility method * fix javadoc issues * adjust licence headers * rename Generator to Codegen for GraphQL classes * renaming, minor enhancement to graphql generator * add graphql server samples * add windows batch files, rename directory
This commit is contained in:
parent
01ac429954
commit
4be605bcb7
32
bin/graphql-schema-petstore.sh
Executable file
32
bin/graphql-schema-petstore.sh
Executable 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} -Xmx1024M -DloggerPath=conf/log4j.properties $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/graphql-schema -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g graphql-schema -o samples/config/petstore/graphql-schema -DpackageName=petstore $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
32
bin/graphql-server-petstore.sh
Executable file
32
bin/graphql-server-petstore.sh
Executable 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} -Xmx1024M -DloggerPath=conf/log4j.properties $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/graphql-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g graphql-server -o samples/server/petstore/graphql-server -DpackageName=petstore $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
42
bin/openapi3/graphql-petstore-server.sh
Executable file
42
bin/openapi3/graphql-petstore-server.sh
Executable file
@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
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
|
||||
|
||||
# Make sure that the working directory is the root dir
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
cd "${SCRIPT_DIR}/../"
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
# Make sure that we are regenerating the sample by removing any existing target directory
|
||||
TARGET_DIR="$SCRIPT_DIR/../../samples/server/petstore/graphql-server"
|
||||
if [ -d "$TARGET_DIR" ]; then
|
||||
rm -rf $TARGET_DIR
|
||||
fi
|
||||
|
||||
executable="$SCRIPT_DIR/../../modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t $SCRIPT_DIR/../../modules/openapi-generator/src/main/resources/graphql-server -i $SCRIPT_DIR/../../modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g graphql-server -o $TARGET_DIR $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
10
bin/windows/graphql-petstore-server.bat
Executable file
10
bin/windows/graphql-petstore-server.bat
Executable 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
|
||||
set ags=generate -t modules\openapi-generator\src\main\resources\graphql-server -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g graphql-server -o samples\server\petstore\graphql-server
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
10
bin/windows/graphql-schema-petstore.bat
Executable file
10
bin/windows/graphql-schema-petstore.bat
Executable 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
|
||||
set ags=generate -t modules\openapi-generator\src\main\resources\graphql-schema -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g graphql-schema -o samples\config\petstore\graphql-schema
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
@ -0,0 +1,463 @@
|
||||
/*
|
||||
* 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.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class AbstractGraphQLCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractGraphQLCodegen.class);
|
||||
|
||||
protected String specFolder = "spec";
|
||||
protected String packageName = "openapi2graphql";
|
||||
protected String packageVersion = "1.0.0";
|
||||
protected String apiDocPath = "docs/";
|
||||
protected String modelDocPath = "docs/";
|
||||
|
||||
protected String graphQlInputsPackage = "";
|
||||
|
||||
public AbstractGraphQLCodegen() {
|
||||
super();
|
||||
|
||||
setReservedWordsLowerCase(
|
||||
Arrays.asList(
|
||||
// data type
|
||||
"null", "Int", "Float", "String", "Boolean", "ID",
|
||||
|
||||
// reserved words: TODO
|
||||
"type", "implements", "query", "union", "interface"
|
||||
)
|
||||
);
|
||||
|
||||
defaultIncludes = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"map",
|
||||
"array")
|
||||
);
|
||||
|
||||
languageSpecificPrimitives = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"null",
|
||||
"ID",
|
||||
"Int",
|
||||
"String",
|
||||
"Float",
|
||||
"Boolean")
|
||||
);
|
||||
|
||||
instantiationTypes.clear();
|
||||
|
||||
typeMapping.clear();
|
||||
typeMapping.put("integer", "Int");
|
||||
typeMapping.put("long", "Int");
|
||||
typeMapping.put("number", "Float");
|
||||
typeMapping.put("float", "Float");
|
||||
typeMapping.put("double", "Float");
|
||||
typeMapping.put("boolean", "Boolean");
|
||||
typeMapping.put("string", "String");
|
||||
typeMapping.put("UUID", "ID");
|
||||
typeMapping.put("date", "String");
|
||||
typeMapping.put("DateTime", "String");
|
||||
typeMapping.put("password", "String");
|
||||
// TODO fix mapping
|
||||
typeMapping.put("file", "String");
|
||||
typeMapping.put("binary", "String");
|
||||
typeMapping.put("ByteArray", "String");
|
||||
typeMapping.put("object", "TODO_OBJECT_MAPPING");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
|
||||
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
|
||||
setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION));
|
||||
}
|
||||
|
||||
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
|
||||
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
|
||||
|
||||
additionalProperties.put("apiDocPath", apiDocPath);
|
||||
additionalProperties.put("modelDocPath", modelDocPath);
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
public void setPackageVersion(String packageVersion) {
|
||||
this.packageVersion = packageVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
// Can't start with an underscore, as our fields need to start with an
|
||||
|
||||
// Options?
|
||||
// - MyName
|
||||
// - AName
|
||||
// - TheName
|
||||
// - XName
|
||||
// - X_Name
|
||||
// ... or maybe a suffix?
|
||||
// - Name_ ... think this will work.
|
||||
if (this.reservedWordsMappings().containsKey(name)) {
|
||||
return this.reservedWordsMappings().get(name);
|
||||
}
|
||||
return camelize(name) + '_';
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + File.separator + packageName + File.separator + "api" + File.separator;
|
||||
}
|
||||
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + File.separator + packageName + File.separator + "model" + File.separator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = sanitizeName(name.replaceAll("-", "_"));
|
||||
|
||||
// if it's all uppper case, do nothing
|
||||
if (name.matches("^[A-Z_]*$"))
|
||||
return name;
|
||||
|
||||
name = camelize(name, true);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name))
|
||||
name = escapeReservedWord(name);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (name.matches("^\\d.*"))
|
||||
name = camelize("var_" + name);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
return toVarName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
return camelize(toModelFilename(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
if (!StringUtils.isEmpty(modelNamePrefix)) {
|
||||
name = modelNamePrefix + "_" + name;
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(modelNameSuffix)) {
|
||||
name = name + "_" + modelNameSuffix;
|
||||
}
|
||||
|
||||
name = sanitizeName(name);
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + ("model_" + name));
|
||||
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
||||
}
|
||||
|
||||
// model name starts with number
|
||||
if (name.matches("^\\d.*")) {
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + ("model_" + name));
|
||||
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
||||
}
|
||||
|
||||
return underscore(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiFilename(String name) {
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
// e.g. PetApi.graphql => pet_api.graphql
|
||||
return underscore(name) + "_api";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiTestFilename(String name) {
|
||||
return toApiFilename(name) + "_spec";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelTestFilename(String name) {
|
||||
return toModelFilename(name) + "_spec";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessParameter(CodegenParameter parameter) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiTestFileFolder() {
|
||||
return outputFolder + File.separator + specFolder.replace("/", File.separator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelTestFileFolder() {
|
||||
return outputFolder + File.separator + specFolder.replace("/", File.separator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiDocFileFolder() {
|
||||
return (outputFolder + "/" + apiDocPath).replace('/', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelDocFileFolder() {
|
||||
return (outputFolder + "/" + modelDocPath).replace('/', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelDocFilename(String name) {
|
||||
return toModelName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiDocFilename(String name) {
|
||||
return toApiName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
return underscore(super.toApiName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
Schema inner = ap.getItems();
|
||||
return "[" + getTypeDeclaration(inner) + "]";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
return getTypeDeclaration(inner);
|
||||
}
|
||||
|
||||
// Not using the supertype invocation, because we want to UpperCamelize
|
||||
// the type.
|
||||
String schemaType = getSchemaType(p);
|
||||
String nullable = ModelUtils.isNullable(p) ? "" : "!";
|
||||
/*
|
||||
if (p != null && Boolean.TRUE.equals(p.getNullable())) {
|
||||
nullable = "";
|
||||
} else {
|
||||
nullable = "!";
|
||||
}*/
|
||||
|
||||
if (typeMapping.containsKey(schemaType)) {
|
||||
return typeMapping.get(schemaType) + nullable;
|
||||
}
|
||||
|
||||
if (languageSpecificPrimitives.contains(schemaType)) {
|
||||
return schemaType + nullable;
|
||||
}
|
||||
|
||||
return toModelName(schemaType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchemaType(Schema p) {
|
||||
String schemaType = super.getSchemaType(p);
|
||||
String type = null;
|
||||
if (typeMapping.containsKey(schemaType)) {
|
||||
type = typeMapping.get(schemaType);
|
||||
if (languageSpecificPrimitives.contains(type))
|
||||
return (type);
|
||||
} else {
|
||||
type = schemaType;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toOperationId(String operationId) {
|
||||
String sanitizedOperationId = sanitizeName(operationId);
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(sanitizedOperationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + underscore("call_" + operationId));
|
||||
sanitizedOperationId = "call_" + sanitizedOperationId;
|
||||
}
|
||||
|
||||
return camelize(sanitizedOperationId, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean needToImport(String type) {
|
||||
return !defaultIncludes.contains(type)
|
||||
&& !languageSpecificPrimitives.contains(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeQuotationMark(String input) {
|
||||
// remove " to avoid code injection
|
||||
return input.replace("\"", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeUnsafeCharacters(String input) {
|
||||
return input.replace("]]", "] ]");
|
||||
}
|
||||
|
||||
public Map<String, String> createMapping(String key, String value) {
|
||||
Map<String, String> customImport = new HashMap<String, String>();
|
||||
customImport.put(key, value);
|
||||
|
||||
return customImport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumValue(String value, String datatype) {
|
||||
if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
|
||||
return value;
|
||||
} else {
|
||||
return escapeText(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumDefaultValue(String value, String datatype) {
|
||||
return datatype + "_" + value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumVarName(String name, String datatype) {
|
||||
if (name.length() == 0) {
|
||||
return "EMPTY";
|
||||
}
|
||||
|
||||
// number
|
||||
if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
|
||||
String varName = name;
|
||||
varName = varName.replaceAll("-", "MINUS_");
|
||||
varName = varName.replaceAll("\\+", "PLUS_");
|
||||
varName = varName.replaceAll("\\.", "_DOT_");
|
||||
return varName;
|
||||
}
|
||||
|
||||
// for symbol, e.g. $, #
|
||||
if (getSymbolName(name) != null) {
|
||||
return getSymbolName(name).toUpperCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
// string
|
||||
String enumName = sanitizeName(underscore(name).toUpperCase(Locale.ROOT));
|
||||
enumName = enumName.replaceFirst("^_", "");
|
||||
enumName = enumName.replaceFirst("_$", "");
|
||||
|
||||
if (isReservedWord(enumName) || enumName.matches("\\d.*")) { // reserved word or starts with number
|
||||
return escapeReservedWord(enumName);
|
||||
} else {
|
||||
return enumName;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
String enumName = toModelName(property.name);
|
||||
|
||||
// remove [] for array or map of enum
|
||||
enumName = enumName.replace("[]", "");
|
||||
|
||||
if (enumName.matches("\\d.*")) { // starts with number
|
||||
return "_" + enumName;
|
||||
} else {
|
||||
return enumName;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelImport(String name) {
|
||||
if (needToImport(toModelName(name))) {
|
||||
return toModelName(name);
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperations(Map<String, Object> operations) {
|
||||
Map<String, Object> objs = (Map<String, Object>) operations.get("operations");
|
||||
|
||||
for (CodegenOperation op : (List<CodegenOperation>) objs.get("operation")) {
|
||||
// non GET/HEAD methods are mutation
|
||||
if (!"GET".equals(op.httpMethod.toUpperCase(Locale.ROOT)) && !"HEAD".equals(op.httpMethod.toUpperCase(Locale.ROOT))) {
|
||||
op.vendorExtensions.put("x-is-mutation", Boolean.TRUE);
|
||||
}
|
||||
for (CodegenParameter p : op.allParams) {
|
||||
// TODO check and adjust!
|
||||
// {{#vendorExtensions.x-graphql-nullable}}?{{/vendorExtensions.x-graphql-nullable}}
|
||||
if (p.required) {
|
||||
op.vendorExtensions.put("x-graphql-nullable", Boolean.FALSE);
|
||||
} else {
|
||||
op.vendorExtensions.put("x-graphql-nullable", Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
public String graphQlInputsPackage() {
|
||||
return graphQlInputsPackage;
|
||||
}
|
||||
|
||||
public String graphQlInputsFileFolder() {
|
||||
return outputFolder + File.separator + graphQlInputsPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
public String graphQlInputsFilename(String templateName, String tag) {
|
||||
String suffix = apiTemplateFiles().get(templateName);
|
||||
return graphQlInputsFileFolder() + File.separator + tographQlInputsFilename(tag) + suffix;
|
||||
}
|
||||
|
||||
public String tographQlInputsFilename(String name) {
|
||||
return tographQlInputsName(name);
|
||||
}
|
||||
|
||||
public String tographQlInputsName(String name) {
|
||||
if (name.length() == 0) {
|
||||
return "EmptyInput";
|
||||
}
|
||||
|
||||
return camelize(name) + "Input";
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* 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 org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class GraphQLSchemaCodegen extends AbstractGraphQLCodegen implements CodegenConfig {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GraphQLSchemaCodegen.class);
|
||||
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CONFIG;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "graphql-schema";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates GraphQL schema files (beta)";
|
||||
}
|
||||
|
||||
public GraphQLSchemaCodegen() {
|
||||
super();
|
||||
outputFolder = "generated-code/graphql-schema";
|
||||
modelTemplateFiles.put("model.mustache", ".graphql");
|
||||
apiTemplateFiles.put("api.mustache", ".graphql");
|
||||
embeddedTemplateDir = templateDir = "graphql-schema";
|
||||
hideGenerationTimestamp = Boolean.TRUE;
|
||||
|
||||
|
||||
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
||||
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
||||
|
||||
|
||||
cliOptions.clear();
|
||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "GraphQL package name (convention: lowercase).")
|
||||
.defaultValue("openapi2graphql"));
|
||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "GraphQL package version.")
|
||||
.defaultValue("1.0.0"));
|
||||
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC)
|
||||
.defaultValue(Boolean.TRUE.toString()));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
//apiTestTemplateFiles.put("api_test.mustache", ".graphql");
|
||||
//modelTestTemplateFiles.put("model_test.mustache", ".graphql");
|
||||
|
||||
apiDocTemplateFiles.clear(); // TODO: add api doc template
|
||||
modelDocTemplateFiles.clear(); // TODO: add model doc template
|
||||
|
||||
modelPackage = packageName;
|
||||
apiPackage = packageName;
|
||||
|
||||
//supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
//supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||
//supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"))
|
||||
//supportingFiles.add(new SupportingFile(".travis.yml", "", ".travis.yml"));
|
||||
}
|
||||
}
|
@ -0,0 +1,147 @@
|
||||
/*
|
||||
* 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.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class GraphQLServerCodegen extends AbstractGraphQLCodegen implements CodegenConfig {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GraphQLServerCodegen.class);
|
||||
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.SERVER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "graphql-server";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a GraphQL express server including it's types, queries, mutations, (resolvers)";
|
||||
}
|
||||
|
||||
public GraphQLServerCodegen() {
|
||||
super();
|
||||
|
||||
packageName = "openapi3graphql-server";
|
||||
packageVersion = "1.0.0";
|
||||
|
||||
outputFolder = "generated-code/graphql-server";
|
||||
embeddedTemplateDir = templateDir = "graphql-server";
|
||||
|
||||
hideGenerationTimestamp = Boolean.TRUE;
|
||||
|
||||
apiTemplateFiles.put("api.mustache", ".graphql");
|
||||
apiTemplateFiles.put("resolvers.mustache", "_resolver.js");
|
||||
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
||||
modelTemplateFiles.put("model.mustache", ".graphql");
|
||||
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
||||
// TODO check why api doc is not written
|
||||
|
||||
cliOptions.clear();
|
||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "GraphQL express server package name (convention: lowercase).")
|
||||
.defaultValue("openapi3graphql-server"));
|
||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "GraphQL express server package version.")
|
||||
.defaultValue("1.0.0"));
|
||||
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC)
|
||||
.defaultValue(Boolean.TRUE.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
// TODO: add api test template
|
||||
//apiTestTemplateFiles.put("api_test.mustache", ".graphql");
|
||||
|
||||
// TODO: add model test template
|
||||
//modelTestTemplateFiles.put("model_test.mustache", ".graphql");
|
||||
modelTestTemplateFiles.clear();
|
||||
|
||||
modelPackage = packageName;
|
||||
apiPackage = packageName;
|
||||
|
||||
String supportFolder = apiPackage().replace('.', File.separatorChar);
|
||||
|
||||
// Dynamic express/graphql related stuff
|
||||
supportingFiles.add(new SupportingFile("schema.graphql.mustache", supportFolder, "schema.graphql"));
|
||||
|
||||
// General stuff
|
||||
supportingFiles.add(new SupportingFile(".gitignore", supportFolder, ".gitignore"));
|
||||
supportingFiles.add(new SupportingFile("README.mustache", supportFolder, "README.md"));
|
||||
supportingFiles.add(new SupportingFile("package.json.mustache", supportFolder, "package.json"));
|
||||
supportingFiles.add(new SupportingFile("server.js", supportFolder, "server.js"));
|
||||
supportingFiles.add(new SupportingFile("start.js", supportFolder, "start.js"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
Schema inner = ap.getItems();
|
||||
|
||||
// IMPORTANT NOTE we add the braces within template because there we have the possibility to differenciate
|
||||
// between some specific types for GraphQL:
|
||||
// return "[" + getTypeDeclaration(inner) + "]";
|
||||
return getTypeDeclaration(inner);
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
|
||||
return getTypeDeclaration(inner);
|
||||
}
|
||||
|
||||
// IMPORANT NOTE Not using the supertype invocation, because we want to UpperCamelize the type:
|
||||
String schemaType = getSchemaType(p);
|
||||
String nullable = ModelUtils.isNullable(p) ? "" : "!";
|
||||
|
||||
if (typeMapping.containsKey(schemaType)) {
|
||||
return typeMapping.get(schemaType) + nullable;
|
||||
}
|
||||
|
||||
if (languageSpecificPrimitives.contains(schemaType)) {
|
||||
return schemaType + nullable;
|
||||
}
|
||||
|
||||
return toModelName(schemaType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
String enumName = toModelName(property.name);
|
||||
|
||||
// Remove [] for array or map of ENUM
|
||||
enumName = enumName.replace("[]", "");
|
||||
|
||||
// ENUM starts with a number
|
||||
if (enumName.matches("\\d.*")) {
|
||||
return StringUtils.capitalize("_" + enumName) + "Enum";
|
||||
} else {
|
||||
return StringUtils.capitalize(enumName) + "Enum";
|
||||
}
|
||||
}
|
||||
}
|
@ -822,4 +822,20 @@ public class ModelUtils {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isNullable(Schema schema) {
|
||||
if (schema == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(schema.getNullable())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (schema.getExtensions() != null && schema.getExtensions().get("x-nullable") != null) {
|
||||
return Boolean.valueOf(schema.getExtensions().get("x-nullable").toString());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,8 @@ org.openapitools.codegen.languages.FinchServerCodegen
|
||||
org.openapitools.codegen.languages.GoClientCodegen
|
||||
org.openapitools.codegen.languages.GoServerCodegen
|
||||
org.openapitools.codegen.languages.GoGinServerCodegen
|
||||
org.openapitools.codegen.languages.GraphQLSchemaCodegen
|
||||
org.openapitools.codegen.languages.GraphQLServerCodegen
|
||||
org.openapitools.codegen.languages.GroovyClientCodegen
|
||||
org.openapitools.codegen.languages.KotlinClientCodegen
|
||||
org.openapitools.codegen.languages.KotlinServerCodegen
|
||||
@ -98,4 +100,4 @@ org.openapitools.codegen.languages.TypeScriptAxiosClientCodegen
|
||||
org.openapitools.codegen.languages.TypeScriptFetchClientCodegen
|
||||
org.openapitools.codegen.languages.TypeScriptInversifyClientCodegen
|
||||
org.openapitools.codegen.languages.TypeScriptJqueryClientCodegen
|
||||
org.openapitools.codegen.languages.TypeScriptNodeClientCodegen
|
||||
org.openapitools.codegen.languages.TypeScriptNodeClientCodegen
|
||||
|
@ -0,0 +1,96 @@
|
||||
# Lua API client for {{packageName}}
|
||||
|
||||
{{#appDescription}}
|
||||
{{{appDescription}}}
|
||||
{{/appDescription}}
|
||||
|
||||
## Overview
|
||||
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client.
|
||||
|
||||
- API version: {{appVersion}}
|
||||
- Package version: {{packageVersion}}
|
||||
{{^hideGenerationTimestamp}}
|
||||
- Build date: {{generatedDate}}
|
||||
{{/hideGenerationTimestamp}}
|
||||
- Build package: {{generatorClass}}
|
||||
{{#infoUrl}}
|
||||
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
|
||||
{{/infoUrl}}
|
||||
|
||||
## Installation
|
||||
Put the package under your project folder and add the following in import:
|
||||
```
|
||||
"./{{packageName}}"
|
||||
```
|
||||
|
||||
## Documentation for API Endpoints
|
||||
|
||||
All URIs are relative to *{{basePath}}*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
|
||||
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
||||
|
||||
## Documentation For Models
|
||||
|
||||
{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md)
|
||||
{{/model}}{{/models}}
|
||||
|
||||
## Documentation For Authorization
|
||||
{{^authMethods}} Endpoints do not require authorization.
|
||||
{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}}
|
||||
{{#authMethods}}
|
||||
## {{{name}}}
|
||||
{{#isApiKey}}- **Type**: API key
|
||||
|
||||
Example
|
||||
```
|
||||
auth := context.WithValue(context.TODO(), sw.ContextAPIKey, sw.APIKey{
|
||||
Key: "APIKEY",
|
||||
Prefix: "Bearer", // Omit if not necessary.
|
||||
})
|
||||
r, err := client.Service.Operation(auth, args)
|
||||
```
|
||||
{{/isApiKey}}
|
||||
{{#isBasic}}- **Type**: HTTP basic authentication
|
||||
|
||||
Example
|
||||
```
|
||||
auth := context.WithValue(context.TODO(), sw.ContextBasicAuth, sw.BasicAuth{
|
||||
UserName: "username",
|
||||
Password: "password",
|
||||
})
|
||||
r, err := client.Service.Operation(auth, args)
|
||||
```
|
||||
{{/isBasic}}
|
||||
{{#isOAuth}}- **Type**: OAuth
|
||||
- **Flow**: {{{flow}}}
|
||||
- **Authorization URL**: {{{authorizationUrl}}}
|
||||
- **Scopes**: {{^scopes}}N/A{{/scopes}}
|
||||
{{#scopes}} - **{{{scope}}}**: {{{description}}}
|
||||
{{/scopes}}
|
||||
|
||||
Example
|
||||
```
|
||||
auth := context.WithValue(context.TODO(), sw.ContextAccessToken, "ACCESSTOKENSTRING")
|
||||
r, err := client.Service.Operation(auth, args)
|
||||
```
|
||||
|
||||
Or via OAuth2 module to automatically refresh tokens and perform user authentication.
|
||||
```
|
||||
import "golang.org/x/oauth2"
|
||||
|
||||
/ .. Perform OAuth2 round trip request and obtain a token .. //
|
||||
|
||||
tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token)
|
||||
auth := context.WithValue(oauth2.NoContext, sw.ContextOAuth2, tokenSource)
|
||||
r, err := client.Service.Operation(auth, args)
|
||||
```
|
||||
{{/isOAuth}}
|
||||
{{/authMethods}}
|
||||
|
||||
## Author
|
||||
|
||||
{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}}
|
||||
{{/hasMore}}{{/apis}}{{/apiInfo}}
|
@ -0,0 +1,47 @@
|
||||
{{>partial_header}}
|
||||
# package {{packageName}}
|
||||
|
||||
# {{classname}}
|
||||
|
||||
{{#operations}}
|
||||
type mutation {
|
||||
{{#operation}}
|
||||
{{#vendorExtensions.x-is-mutation}}
|
||||
{{#summary}}
|
||||
# {{summary}}
|
||||
{{/summary}}
|
||||
{{#notes}}
|
||||
# {{notes}}
|
||||
{{/notes}}
|
||||
{{#allParams}}
|
||||
# @param {{dataType}} {{paramName}} {{description}}
|
||||
{{/allParams}}
|
||||
# @return [{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}null{{/returnType}}]
|
||||
{{operationId}}({{#allParams}}{{paramName}}: {{dataType}}{{#hasMore}}, {{/hasMore}}{{/allParams}}): {{#returnType}}{{.}}{{/returnType}}{{^returnType}}null{{/returnType}}
|
||||
|
||||
{{/vendorExtensions.x-is-mutation}}
|
||||
{{/operation}}
|
||||
}
|
||||
|
||||
{{/operations}}
|
||||
{{#operations}}
|
||||
type query {
|
||||
{{#operation}}
|
||||
{{^vendorExtensions.x-is-mutation}}
|
||||
{{#summary}}
|
||||
# {{summary}}
|
||||
{{/summary}}
|
||||
{{#notes}}
|
||||
# {{notes}}
|
||||
{{/notes}}
|
||||
{{#allParams}}
|
||||
# @param {{dataType}} {{paramName}} {{description}}
|
||||
{{/allParams}}
|
||||
# @return [{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}null{{/returnType}}]
|
||||
{{operationId}}({{#allParams}}{{paramName}}: {{dataType}}{{#hasMore}}, {{/hasMore}}{{/allParams}}): {{#returnType}}{{.}}{{/returnType}}{{^returnType}}null{{/returnType}}
|
||||
|
||||
{{/vendorExtensions.x-is-mutation}}
|
||||
{{/operation}}
|
||||
}
|
||||
|
||||
{{/operations}}
|
@ -0,0 +1,5 @@
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
# {{{operationId}}}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
@ -0,0 +1,10 @@
|
||||
{{> partial_header}}
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
{{#models}}
|
||||
# TODO
|
||||
{{#model}}
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="{{{gitUserId}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||
fi
|
||||
|
||||
if [ "$git_repo_id" = "" ]; then
|
||||
git_repo_id="{{{gitRepoId}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||
fi
|
||||
|
||||
if [ "$release_note" = "" ]; then
|
||||
release_note="{{{releaseNote}}}"
|
||||
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||
fi
|
||||
|
||||
# Initialize the local directory as a Git repository
|
||||
git init
|
||||
|
||||
# Adds the files in the local repository and stages them for commit.
|
||||
git add .
|
||||
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
git_remote=`git remote`
|
||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
|
@ -0,0 +1,40 @@
|
||||
# Compiled Lua sources
|
||||
luac.out
|
||||
|
||||
# luarocks build files
|
||||
*.src.rock
|
||||
*.zip
|
||||
*.tar.gz
|
||||
|
||||
# Object files
|
||||
*.o
|
||||
*.os
|
||||
*.ko
|
||||
*.obj
|
||||
*.elf
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Libraries
|
||||
*.lib
|
||||
*.a
|
||||
*.la
|
||||
*.lo
|
||||
*.def
|
||||
*.exp
|
||||
|
||||
# Shared objects (inc. Windows DLLs)
|
||||
*.dll
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
@ -0,0 +1,33 @@
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
{{>partial_header}}
|
||||
{{#description}}
|
||||
# {{description}}
|
||||
{{/description}}
|
||||
type {{classname}} {
|
||||
|
||||
{{#vars}}
|
||||
{{#description}}
|
||||
# {{description}}
|
||||
{{/description}}
|
||||
{{baseName}}: {{datatypeWithEnum}}
|
||||
|
||||
{{/vars}}
|
||||
}
|
||||
{{#vars}}
|
||||
{{#isEnum}}
|
||||
|
||||
{{#description}}
|
||||
# {{description}}
|
||||
{{/description}}
|
||||
enum {{enumName}} {
|
||||
{{#allowableValues}}
|
||||
{{#values}}
|
||||
{{.}}
|
||||
{{/values}}
|
||||
{{/allowableValues}}
|
||||
}
|
||||
{{/isEnum}}
|
||||
{{/vars}}
|
||||
{{/model}}
|
||||
{{/models}}
|
@ -0,0 +1,11 @@
|
||||
{{#models}}{{#model}}# {{classname}}
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{^isContainer}}{{^isDateTime}}*{{/isDateTime}}{{/isContainer}}{{{dataType}}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
|
||||
{{/vars}}
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
{{/model}}{{/models}}
|
@ -0,0 +1,23 @@
|
||||
{{> partial_header}}
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
--[[
|
||||
Unit tests for {{{packageName}}}.model.{{{classname}}}
|
||||
Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||
Please update as you see appropriate
|
||||
]]
|
||||
describe("{{classname}}", function()
|
||||
local {{{packageName}}}_{{{classname}}} = require "{{{packageName}}}.model.{{{classname}}}"
|
||||
|
||||
{{#vars}}
|
||||
-- unit tests for the property '{{{name}}}'
|
||||
describe("property {{{name}}} test", function()
|
||||
it("should work", function()
|
||||
-- TODO assertion here: http://olivinelabs.com/busted/#asserts
|
||||
end)
|
||||
end)
|
||||
|
||||
{{/vars}}
|
||||
end)
|
||||
{{/model}}
|
||||
{{/models}}
|
@ -0,0 +1,14 @@
|
||||
{{#appName}}
|
||||
# {{{appName}}}
|
||||
{{/appName}}
|
||||
{{#appDescription}}
|
||||
# {{{appDescription}}}
|
||||
{{/appDescription}}
|
||||
{{#version}}
|
||||
# OpenAPI spec version: {{{version}}}
|
||||
{{/version}}
|
||||
{{#infoEmail}}
|
||||
# Contact: {{{infoEmail}}}
|
||||
{{/infoEmail}}
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
#
|
8
modules/openapi-generator/src/main/resources/graphql-server/.gitignore
vendored
Normal file
8
modules/openapi-generator/src/main/resources/graphql-server/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# MacOS
|
||||
.DS_Store
|
||||
|
||||
# IDE
|
||||
/.idea
|
||||
|
||||
# JS specific
|
||||
/node_modules
|
@ -0,0 +1,20 @@
|
||||
# GraphQL express API server
|
||||
|
||||
{{#appDescription}}
|
||||
{{{appDescription}}}
|
||||
{{/appDescription}}
|
||||
|
||||
## Requirements
|
||||
|
||||
- node 10+
|
||||
|
||||
## Gettings started
|
||||
|
||||
npm install
|
||||
npm run start
|
||||
|
||||
# TODOs
|
||||
|
||||
- use `ID`-type for unique identifiers instead of `Int` (detect UUID)
|
||||
- add example responses to resolvers.mustache
|
||||
- support for union types
|
@ -0,0 +1,55 @@
|
||||
{{>partial_header_graphql}}
|
||||
# package {{packageName}}
|
||||
|
||||
# {{classname}}
|
||||
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
{{#vendorExtensions.x-is-mutation}}{{#hasParams}}
|
||||
|
||||
input {{operationId}}Input {
|
||||
{{#allParams}}
|
||||
{{#description}}# {{description}}{{/description}}
|
||||
{{paramName}}: {{#isContainer}}[{{/isContainer}}{{dataType}}{{#isListContainer}}Input{{/isListContainer}}{{#isModel}}Input{{/isModel}}{{#isContainer}}]{{/isContainer}}{{#hasMore}}, {{/hasMore}}
|
||||
{{/allParams}}
|
||||
}{{/hasParams}}{{/vendorExtensions.x-is-mutation}}{{/operation}}
|
||||
|
||||
type Mutation {
|
||||
{{#operation}}
|
||||
{{#vendorExtensions.x-is-mutation}}
|
||||
{{#summary}}
|
||||
# {{summary}}
|
||||
{{/summary}}
|
||||
{{#notes}}
|
||||
# {{notes}}
|
||||
{{/notes}}
|
||||
{{#allParams}}
|
||||
# @param {{dataType}} {{paramName}} {{description}}
|
||||
{{/allParams}}
|
||||
# @return [{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Boolean{{/returnType}}]
|
||||
{{operationId}}{{#hasParams}}(input: {{operationId}}Input!){{/hasParams}}: {{#returnType}}{{.}}{{/returnType}}{{^returnType}}Boolean{{/returnType}}
|
||||
{{/vendorExtensions.x-is-mutation}}
|
||||
{{/operation}}
|
||||
}
|
||||
|
||||
{{/operations}}
|
||||
{{#operations}}
|
||||
type Query {
|
||||
{{#operation}}
|
||||
{{^vendorExtensions.x-is-mutation}}
|
||||
{{#summary}}
|
||||
# {{summary}}
|
||||
{{/summary}}
|
||||
{{#notes}}
|
||||
# {{notes}}
|
||||
{{/notes}}
|
||||
{{#allParams}}
|
||||
# @param {{dataType}} {{paramName}} {{description}}
|
||||
{{/allParams}}
|
||||
# @return [{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Boolean{{/returnType}}]
|
||||
{{operationId}}{{#hasParams}}({{#allParams}}{{paramName}}: {{dataType}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{/hasParams}}: {{#returnType}}{{.}}{{/returnType}}{{^returnType}}Boolean{{/returnType}}
|
||||
{{/vendorExtensions.x-is-mutation}}
|
||||
{{/operation}}
|
||||
}
|
||||
|
||||
{{/operations}}
|
@ -0,0 +1,21 @@
|
||||
# {{classname}}{{#description}}
|
||||
{{description}}{{/description}}
|
||||
|
||||
All URIs are relative to *{{basePath}}*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
|
||||
{{/operation}}{{/operations}}
|
||||
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
<a name="{{operationId}}"></a>
|
||||
# **{{operationId}}**
|
||||
> {{#returnType}}{{returnType}} {{/returnType}}{{operationId}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
|
||||
|
||||
{{summary}}{{#notes}}
|
||||
|
||||
{{notes}}{{/notes}}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
@ -0,0 +1,40 @@
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
{{>partial_header_graphql}}
|
||||
{{#description}}
|
||||
# {{{description}}}
|
||||
{{/description}}
|
||||
type {{classname}} {
|
||||
{{#vars}}
|
||||
{{#description}}
|
||||
# {{{description}}}
|
||||
{{/description}}
|
||||
{{baseName}}: {{#isEnum}}{{classname}}{{datatypeWithEnum}}{{/isEnum}}{{^isEnum}}{{datatypeWithEnum}}{{/isEnum}}
|
||||
{{/vars}}
|
||||
}
|
||||
|
||||
input {{classname}}Input {
|
||||
{{#vars}}
|
||||
{{#description}}
|
||||
# {{{description}}}
|
||||
{{/description}}
|
||||
{{baseName}}: {{#isEnum}}{{classname}}{{datatypeWithEnum}}{{/isEnum}}{{^isEnum}}{{#isContainer}}[{{datatypeWithEnum}}{{#complexType}}Input{{/complexType}}]{{/isContainer}}{{^isContainer}}{{datatypeWithEnum}}{{#isModel}}Input{{/isModel}}{{/isContainer}}{{/isEnum}}
|
||||
{{/vars}}
|
||||
}
|
||||
{{#vars}}
|
||||
{{#isEnum}}
|
||||
|
||||
{{#description}}
|
||||
# {{{description}}}
|
||||
{{/description}}
|
||||
enum {{classname}}{{enumName}} {
|
||||
{{#allowableValues}}
|
||||
{{#values}}
|
||||
{{{.}}}
|
||||
{{/values}}
|
||||
{{/allowableValues}}
|
||||
}
|
||||
{{/isEnum}}
|
||||
{{/vars}}
|
||||
{{/model}}
|
||||
{{/models}}
|
@ -0,0 +1,11 @@
|
||||
{{#models}}{{#model}}# {{classname}}
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{^isContainer}}{{^isDateTime}}*{{/isDateTime}}{{/isContainer}}{{{dataType}}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
|
||||
{{/vars}}
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
{{/model}}{{/models}}
|
@ -0,0 +1,23 @@
|
||||
{{> partial_header}}
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
--[[
|
||||
Unit tests for {{{packageName}}}.model.{{{classname}}}
|
||||
Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||
Please update as you see appropriate
|
||||
]]
|
||||
describe("{{classname}}", function()
|
||||
local {{{packageName}}}_{{{classname}}} = require "{{{packageName}}}.model.{{{classname}}}"
|
||||
|
||||
{{#vars}}
|
||||
-- unit tests for the property '{{{name}}}'
|
||||
describe("property {{{name}}} test", function()
|
||||
it("should work", function()
|
||||
-- TODO assertion here: http://olivinelabs.com/busted/#asserts
|
||||
end)
|
||||
end)
|
||||
|
||||
{{/vars}}
|
||||
end)
|
||||
{{/model}}
|
||||
{{/models}}
|
@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "graphql-server",
|
||||
"version": "1.0.0",
|
||||
"description": "{{#appDescription}} {{{appDescription}}} {{/appDescription}}",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "node start.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"express": "latest",
|
||||
"graphql": "latest",
|
||||
"apollo-server-express": "latest",
|
||||
"graphql-combine": "latest",
|
||||
"lodash": "latest",
|
||||
"path": "latest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-register": "latest",
|
||||
"babel-preset-env": "latest"
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* {{#appName}}
|
||||
* {{{appName}}}
|
||||
* {{/appName}}
|
||||
* {{#appDescription}}
|
||||
* {{{appDescription}}}
|
||||
* {{/appDescription}}
|
||||
* {{#version}}Version: {{{version}}}{{/version}}
|
||||
* {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
|
||||
* Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
*/
|
@ -0,0 +1,9 @@
|
||||
# {{#appName}}
|
||||
# {{{appName}}}
|
||||
# {{/appName}}
|
||||
# {{#appDescription}}
|
||||
# {{{appDescription}}}
|
||||
# {{/appDescription}}
|
||||
# {{#version}}Version: {{{version}}}{{/version}}
|
||||
# {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
@ -0,0 +1,34 @@
|
||||
{{>partial_header}}
|
||||
// package {{packageName}}
|
||||
|
||||
// {{classname}}
|
||||
|
||||
export default {
|
||||
Query: {
|
||||
{{#operations}}
|
||||
{{#operation}}{{^vendorExtensions.x-is-mutation}}
|
||||
// @return {{returnType}}
|
||||
{{operationId}}: ({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) => {
|
||||
return {
|
||||
{{#allParams}}"{{paramName}}": "{{example}}"{{#hasMore}},
|
||||
{{/hasMore}}{{/allParams}}
|
||||
};
|
||||
},
|
||||
{{/vendorExtensions.x-is-mutation}}{{/operation}}
|
||||
{{/operations}}
|
||||
},
|
||||
|
||||
Mutation: {
|
||||
{{#operations}}
|
||||
{{#operation}}{{#vendorExtensions.x-is-mutation}}
|
||||
// @return {{returnType}}
|
||||
{{operationId}}: ({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) => {
|
||||
return {
|
||||
{{#allParams}}"{{paramName}}": "{{example}}"{{#hasMore}},
|
||||
{{/hasMore}}{{/allParams}}
|
||||
};
|
||||
},
|
||||
{{/vendorExtensions.x-is-mutation}}{{/operation}}
|
||||
{{/operations}}
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
interface Entity {
|
||||
id: Int!
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
import express from 'express';
|
||||
import {ApolloServer, graphiqlExpress, graphqlExpress} from 'apollo-server-express'
|
||||
import combine from 'graphql-combine'
|
||||
import path from 'path'
|
||||
|
||||
const PORT = 4000 || process.env;
|
||||
|
||||
// Initialize the app
|
||||
const app = express();
|
||||
|
||||
// Get combined typeDefs and resolvers object
|
||||
const {typeDefs, resolvers} = combine({
|
||||
// TypeDefs glob pattern
|
||||
typeDefs: path.join(__dirname, '**/*.graphql'),
|
||||
|
||||
// Resolvers glob pattern
|
||||
resolvers: path.join(__dirname, 'api/*_resolver.js')
|
||||
});
|
||||
|
||||
// GraphQL: Schema
|
||||
const server = new ApolloServer({
|
||||
typeDefs: typeDefs,
|
||||
resolvers: resolvers,
|
||||
playground: {
|
||||
endpoint: `http://localhost:${PORT}/graphql`,
|
||||
settings: {
|
||||
'editor.theme': 'light'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
server.applyMiddleware({app: app});
|
||||
|
||||
// Start the server
|
||||
app.listen(PORT, () => {
|
||||
console.log(`You can reach GraphQL at: http://localhost:${PORT}/graphql`);
|
||||
});
|
@ -0,0 +1,7 @@
|
||||
// Transpile all code following this line with babel and use 'env' (aka ES6) preset.
|
||||
require('babel-register')({
|
||||
presets: ['env']
|
||||
});
|
||||
|
||||
// Import the rest of our application.
|
||||
module.exports = require('./server.js');
|
@ -0,0 +1,11 @@
|
||||
{{>partial_header}}
|
||||
|
||||
import { merge } from 'lodash';
|
||||
{{#models}}{{#model}}
|
||||
import { typeDef as {{classname}} } from './model/{{classFilename}}.js';{{/model}}{{/models}}
|
||||
|
||||
export const typeDefs = [
|
||||
|
||||
{{#models}}{{#model}}{{classname}},
|
||||
{{/model}}{{/models}}
|
||||
].join('\r\n');
|
@ -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,64 @@
|
||||
# OpenAPI Petstore
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
# OpenAPI spec version: 1.0.0
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
#
|
||||
|
||||
# package petstore
|
||||
|
||||
# pet_api
|
||||
|
||||
type mutation {
|
||||
# Add a new pet to the store
|
||||
# @param Pet pet Pet object that needs to be added to the store
|
||||
# @return [null]
|
||||
AddPet(pet: Pet): null
|
||||
|
||||
# Deletes a pet
|
||||
# @param Int! petId Pet id to delete
|
||||
# @param String! apiKey
|
||||
# @return [null]
|
||||
DeletePet(petId: Int!, apiKey: String!): null
|
||||
|
||||
# Update an existing pet
|
||||
# @param Pet pet Pet object that needs to be added to the store
|
||||
# @return [null]
|
||||
UpdatePet(pet: Pet): null
|
||||
|
||||
# Updates a pet in the store with form data
|
||||
# @param Int! petId ID of pet that needs to be updated
|
||||
# @param String! name Updated name of the pet
|
||||
# @param String! status Updated status of the pet
|
||||
# @return [null]
|
||||
UpdatePetWithForm(petId: Int!, name: String!, status: String!): null
|
||||
|
||||
# uploads an image
|
||||
# @param Int! petId ID of pet to update
|
||||
# @param String! additionalMetadata Additional data to pass to server
|
||||
# @param String! file file to upload
|
||||
# @return [ApiResponse]
|
||||
UploadFile(petId: Int!, additionalMetadata: String!, file: String!): ApiResponse
|
||||
|
||||
}
|
||||
|
||||
type query {
|
||||
# Finds Pets by status
|
||||
# Multiple status values can be provided with comma separated strings
|
||||
# @param [String!] status Status values that need to be considered for filter
|
||||
# @return [[Pet]]
|
||||
FindPetsByStatus(status: [String!]): [Pet]
|
||||
|
||||
# Finds Pets by tags
|
||||
# Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
# @param [String!] tags Tags to filter by
|
||||
# @return [[Pet]]
|
||||
FindPetsByTags(tags: [String!]): [Pet]
|
||||
|
||||
# Find pet by ID
|
||||
# Returns a single pet
|
||||
# @param Int! petId ID of pet to return
|
||||
# @return [Pet]
|
||||
GetPetById(petId: Int!): Pet
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,38 @@
|
||||
# OpenAPI Petstore
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
# OpenAPI spec version: 1.0.0
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
#
|
||||
|
||||
# package petstore
|
||||
|
||||
# store_api
|
||||
|
||||
type mutation {
|
||||
# Delete purchase order by ID
|
||||
# For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
# @param String! orderId ID of the order that needs to be deleted
|
||||
# @return [null]
|
||||
DeleteOrder(orderId: String!): null
|
||||
|
||||
# Place an order for a pet
|
||||
# @param Order order order placed for purchasing the pet
|
||||
# @return [Order]
|
||||
PlaceOrder(order: Order): Order
|
||||
|
||||
}
|
||||
|
||||
type query {
|
||||
# Returns pet inventories by status
|
||||
# Returns a map of status codes to quantities
|
||||
# @return [Int!]
|
||||
GetInventory(): Int!
|
||||
|
||||
# Find purchase order by ID
|
||||
# For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
# @param Int! orderId ID of pet that needs to be fetched
|
||||
# @return [Order]
|
||||
GetOrderById(orderId: Int!): Order
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,60 @@
|
||||
# OpenAPI Petstore
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
# OpenAPI spec version: 1.0.0
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
#
|
||||
|
||||
# package petstore
|
||||
|
||||
# user_api
|
||||
|
||||
type mutation {
|
||||
# Create user
|
||||
# This can only be done by the logged in user.
|
||||
# @param User user Created user object
|
||||
# @return [null]
|
||||
CreateUser(user: User): null
|
||||
|
||||
# Creates list of users with given input array
|
||||
# @param [User] user List of user object
|
||||
# @return [null]
|
||||
CreateUsersWithArrayInput(user: [User]): null
|
||||
|
||||
# Creates list of users with given input array
|
||||
# @param [User] user List of user object
|
||||
# @return [null]
|
||||
CreateUsersWithListInput(user: [User]): null
|
||||
|
||||
# Delete user
|
||||
# This can only be done by the logged in user.
|
||||
# @param String! username The name that needs to be deleted
|
||||
# @return [null]
|
||||
DeleteUser(username: String!): null
|
||||
|
||||
# Updated user
|
||||
# This can only be done by the logged in user.
|
||||
# @param String! username name that need to be deleted
|
||||
# @param User user Updated user object
|
||||
# @return [null]
|
||||
UpdateUser(username: String!, user: User): null
|
||||
|
||||
}
|
||||
|
||||
type query {
|
||||
# Get user by user name
|
||||
# @param String! username The name that needs to be fetched. Use user1 for testing.
|
||||
# @return [User]
|
||||
GetUserByName(username: String!): User
|
||||
|
||||
# Logs user into the system
|
||||
# @param String! username The user name for login
|
||||
# @param String! password The password for login in clear text
|
||||
# @return [String!]
|
||||
LoginUser(username: String!, password: String!): String!
|
||||
|
||||
# Logs out current logged in user session
|
||||
# @return [null]
|
||||
LogoutUser(): null
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
# OpenAPI Petstore
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
# OpenAPI spec version: 1.0.0
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
#
|
||||
|
||||
# Describes the result of uploading an image resource
|
||||
type ApiResponse {
|
||||
|
||||
code: Int!
|
||||
|
||||
type: String!
|
||||
|
||||
message: String!
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
# OpenAPI Petstore
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
# OpenAPI spec version: 1.0.0
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
#
|
||||
|
||||
# A category for a pet
|
||||
type Category {
|
||||
|
||||
id: Int!
|
||||
|
||||
name: String!
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
# OpenAPI Petstore
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
# OpenAPI spec version: 1.0.0
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
#
|
||||
|
||||
# An order for a pets from the pet store
|
||||
type Order {
|
||||
|
||||
id: Int!
|
||||
|
||||
petId: Int!
|
||||
|
||||
quantity: Int!
|
||||
|
||||
shipDate: String!
|
||||
|
||||
# Order Status
|
||||
status: Status
|
||||
|
||||
complete: Boolean!
|
||||
|
||||
}
|
||||
|
||||
# Order Status
|
||||
enum Status {
|
||||
placed
|
||||
approved
|
||||
delivered
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
# OpenAPI Petstore
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
# OpenAPI spec version: 1.0.0
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
#
|
||||
|
||||
# A pet for sale in the pet store
|
||||
type Pet {
|
||||
|
||||
id: Int!
|
||||
|
||||
category: Category
|
||||
|
||||
name: String!
|
||||
|
||||
photoUrls: [String!]
|
||||
|
||||
tags: [Tag]
|
||||
|
||||
# pet status in the store
|
||||
status: Status
|
||||
|
||||
}
|
||||
|
||||
# pet status in the store
|
||||
enum Status {
|
||||
available
|
||||
pending
|
||||
sold
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
# OpenAPI Petstore
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
# OpenAPI spec version: 1.0.0
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
#
|
||||
|
||||
# A tag for a pet
|
||||
type Tag {
|
||||
|
||||
id: Int!
|
||||
|
||||
name: String!
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
# OpenAPI Petstore
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
# OpenAPI spec version: 1.0.0
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
#
|
||||
|
||||
# A User who is purchasing from the pet store
|
||||
type User {
|
||||
|
||||
id: Int!
|
||||
|
||||
username: String!
|
||||
|
||||
firstName: String!
|
||||
|
||||
lastName: String!
|
||||
|
||||
email: String!
|
||||
|
||||
password: String!
|
||||
|
||||
phone: String!
|
||||
|
||||
# User Status
|
||||
userStatus: Int!
|
||||
|
||||
}
|
@ -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
|
12
samples/server/petstore/graphql-server/docs/ApiResponse.md
Normal file
12
samples/server/petstore/graphql-server/docs/ApiResponse.md
Normal file
@ -0,0 +1,12 @@
|
||||
# ApiResponse
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**code** | **Int!** | | [optional] [default to null]
|
||||
**Type_** | **String!** | | [optional] [default to null]
|
||||
**message** | **String!** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
11
samples/server/petstore/graphql-server/docs/Category.md
Normal file
11
samples/server/petstore/graphql-server/docs/Category.md
Normal file
@ -0,0 +1,11 @@
|
||||
# Category
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Id_** | **Int!** | | [optional] [default to null]
|
||||
**name** | **String!** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
11
samples/server/petstore/graphql-server/docs/InlineObject.md
Normal file
11
samples/server/petstore/graphql-server/docs/InlineObject.md
Normal file
@ -0,0 +1,11 @@
|
||||
# InlineObject
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **String!** | Updated name of the pet | [optional] [default to null]
|
||||
**status** | **String!** | Updated status of the pet | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
11
samples/server/petstore/graphql-server/docs/InlineObject1.md
Normal file
11
samples/server/petstore/graphql-server/docs/InlineObject1.md
Normal file
@ -0,0 +1,11 @@
|
||||
# InlineObject1
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**additionalMetadata** | **String!** | Additional data to pass to server | [optional] [default to null]
|
||||
**file** | **String!** | file to upload | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
15
samples/server/petstore/graphql-server/docs/Order.md
Normal file
15
samples/server/petstore/graphql-server/docs/Order.md
Normal file
@ -0,0 +1,15 @@
|
||||
# Order
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Id_** | **Int!** | | [optional] [default to null]
|
||||
**petId** | **Int!** | | [optional] [default to null]
|
||||
**quantity** | **Int!** | | [optional] [default to null]
|
||||
**shipDate** | **String!** | | [optional] [default to null]
|
||||
**status** | **String!** | Order Status | [optional] [default to null]
|
||||
**complete** | **Boolean!** | | [optional] [default to false]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
15
samples/server/petstore/graphql-server/docs/Pet.md
Normal file
15
samples/server/petstore/graphql-server/docs/Pet.md
Normal file
@ -0,0 +1,15 @@
|
||||
# Pet
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Id_** | **Int!** | | [optional] [default to null]
|
||||
**category** | [***Category**](Category.md) | | [optional] [default to null]
|
||||
**name** | **String!** | | [default to null]
|
||||
**photoUrls** | **String!** | | [default to null]
|
||||
**tags** | [**Tag**](Tag.md) | | [optional] [default to null]
|
||||
**status** | **String!** | pet status in the store | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
11
samples/server/petstore/graphql-server/docs/Tag.md
Normal file
11
samples/server/petstore/graphql-server/docs/Tag.md
Normal file
@ -0,0 +1,11 @@
|
||||
# Tag
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Id_** | **Int!** | | [optional] [default to null]
|
||||
**name** | **String!** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
17
samples/server/petstore/graphql-server/docs/User.md
Normal file
17
samples/server/petstore/graphql-server/docs/User.md
Normal file
@ -0,0 +1,17 @@
|
||||
# User
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Id_** | **Int!** | | [optional] [default to null]
|
||||
**username** | **String!** | | [optional] [default to null]
|
||||
**firstName** | **String!** | | [optional] [default to null]
|
||||
**lastName** | **String!** | | [optional] [default to null]
|
||||
**email** | **String!** | | [optional] [default to null]
|
||||
**password** | **String!** | | [optional] [default to null]
|
||||
**phone** | **String!** | | [optional] [default to null]
|
||||
**userStatus** | **Int!** | User Status | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
62
samples/server/petstore/graphql-server/docs/pet_api.md
Normal file
62
samples/server/petstore/graphql-server/docs/pet_api.md
Normal file
@ -0,0 +1,62 @@
|
||||
# pet_api
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**AddPet**](pet_api.md#AddPet) | **POST** /pet | Add a new pet to the store
|
||||
[**DeletePet**](pet_api.md#DeletePet) | **DELETE** /pet/{petId} | Deletes a pet
|
||||
[**FindPetsByStatus**](pet_api.md#FindPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status
|
||||
[**FindPetsByTags**](pet_api.md#FindPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags
|
||||
[**GetPetById**](pet_api.md#GetPetById) | **GET** /pet/{petId} | Find pet by ID
|
||||
[**UpdatePet**](pet_api.md#UpdatePet) | **PUT** /pet | Update an existing pet
|
||||
[**UpdatePetWithForm**](pet_api.md#UpdatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data
|
||||
[**UploadFile**](pet_api.md#UploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image
|
||||
|
||||
|
||||
<a name="AddPet"></a>
|
||||
# **AddPet**
|
||||
> AddPet(pet)
|
||||
|
||||
Add a new pet to the store
|
||||
<a name="DeletePet"></a>
|
||||
# **DeletePet**
|
||||
> DeletePet(petId, apiKey)
|
||||
|
||||
Deletes a pet
|
||||
<a name="FindPetsByStatus"></a>
|
||||
# **FindPetsByStatus**
|
||||
> Pet FindPetsByStatus(status)
|
||||
|
||||
Finds Pets by status
|
||||
|
||||
Multiple status values can be provided with comma separated strings
|
||||
<a name="FindPetsByTags"></a>
|
||||
# **FindPetsByTags**
|
||||
> Pet FindPetsByTags(tags)
|
||||
|
||||
Finds Pets by tags
|
||||
|
||||
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
<a name="GetPetById"></a>
|
||||
# **GetPetById**
|
||||
> Pet GetPetById(petId)
|
||||
|
||||
Find pet by ID
|
||||
|
||||
Returns a single pet
|
||||
<a name="UpdatePet"></a>
|
||||
# **UpdatePet**
|
||||
> UpdatePet(pet)
|
||||
|
||||
Update an existing pet
|
||||
<a name="UpdatePetWithForm"></a>
|
||||
# **UpdatePetWithForm**
|
||||
> UpdatePetWithForm(petId, name, status)
|
||||
|
||||
Updates a pet in the store with form data
|
||||
<a name="UploadFile"></a>
|
||||
# **UploadFile**
|
||||
> ApiResponse UploadFile(petId, additionalMetadata, file)
|
||||
|
||||
uploads an image
|
38
samples/server/petstore/graphql-server/docs/store_api.md
Normal file
38
samples/server/petstore/graphql-server/docs/store_api.md
Normal file
@ -0,0 +1,38 @@
|
||||
# store_api
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**DeleteOrder**](store_api.md#DeleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
|
||||
[**GetInventory**](store_api.md#GetInventory) | **GET** /store/inventory | Returns pet inventories by status
|
||||
[**GetOrderById**](store_api.md#GetOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID
|
||||
[**PlaceOrder**](store_api.md#PlaceOrder) | **POST** /store/order | Place an order for a pet
|
||||
|
||||
|
||||
<a name="DeleteOrder"></a>
|
||||
# **DeleteOrder**
|
||||
> DeleteOrder(orderId)
|
||||
|
||||
Delete purchase order by ID
|
||||
|
||||
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
<a name="GetInventory"></a>
|
||||
# **GetInventory**
|
||||
> Int! GetInventory()
|
||||
|
||||
Returns pet inventories by status
|
||||
|
||||
Returns a map of status codes to quantities
|
||||
<a name="GetOrderById"></a>
|
||||
# **GetOrderById**
|
||||
> Order GetOrderById(orderId)
|
||||
|
||||
Find purchase order by ID
|
||||
|
||||
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
<a name="PlaceOrder"></a>
|
||||
# **PlaceOrder**
|
||||
> Order PlaceOrder(order)
|
||||
|
||||
Place an order for a pet
|
62
samples/server/petstore/graphql-server/docs/user_api.md
Normal file
62
samples/server/petstore/graphql-server/docs/user_api.md
Normal file
@ -0,0 +1,62 @@
|
||||
# user_api
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**CreateUser**](user_api.md#CreateUser) | **POST** /user | Create user
|
||||
[**CreateUsersWithArrayInput**](user_api.md#CreateUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array
|
||||
[**CreateUsersWithListInput**](user_api.md#CreateUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array
|
||||
[**DeleteUser**](user_api.md#DeleteUser) | **DELETE** /user/{username} | Delete user
|
||||
[**GetUserByName**](user_api.md#GetUserByName) | **GET** /user/{username} | Get user by user name
|
||||
[**LoginUser**](user_api.md#LoginUser) | **GET** /user/login | Logs user into the system
|
||||
[**LogoutUser**](user_api.md#LogoutUser) | **GET** /user/logout | Logs out current logged in user session
|
||||
[**UpdateUser**](user_api.md#UpdateUser) | **PUT** /user/{username} | Updated user
|
||||
|
||||
|
||||
<a name="CreateUser"></a>
|
||||
# **CreateUser**
|
||||
> CreateUser(user)
|
||||
|
||||
Create user
|
||||
|
||||
This can only be done by the logged in user.
|
||||
<a name="CreateUsersWithArrayInput"></a>
|
||||
# **CreateUsersWithArrayInput**
|
||||
> CreateUsersWithArrayInput(user)
|
||||
|
||||
Creates list of users with given input array
|
||||
<a name="CreateUsersWithListInput"></a>
|
||||
# **CreateUsersWithListInput**
|
||||
> CreateUsersWithListInput(user)
|
||||
|
||||
Creates list of users with given input array
|
||||
<a name="DeleteUser"></a>
|
||||
# **DeleteUser**
|
||||
> DeleteUser(username)
|
||||
|
||||
Delete user
|
||||
|
||||
This can only be done by the logged in user.
|
||||
<a name="GetUserByName"></a>
|
||||
# **GetUserByName**
|
||||
> User GetUserByName(username)
|
||||
|
||||
Get user by user name
|
||||
<a name="LoginUser"></a>
|
||||
# **LoginUser**
|
||||
> String! LoginUser(username, password)
|
||||
|
||||
Logs user into the system
|
||||
<a name="LogoutUser"></a>
|
||||
# **LogoutUser**
|
||||
> LogoutUser()
|
||||
|
||||
Logs out current logged in user session
|
||||
<a name="UpdateUser"></a>
|
||||
# **UpdateUser**
|
||||
> UpdateUser(username, user)
|
||||
|
||||
Updated user
|
||||
|
||||
This can only be done by the logged in user.
|
8
samples/server/petstore/graphql-server/openapi3graphql-server/.gitignore
vendored
Normal file
8
samples/server/petstore/graphql-server/openapi3graphql-server/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# MacOS
|
||||
.DS_Store
|
||||
|
||||
# IDE
|
||||
/.idea
|
||||
|
||||
# JS specific
|
||||
/node_modules
|
@ -0,0 +1,18 @@
|
||||
# GraphQL express API server
|
||||
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
## Requirements
|
||||
|
||||
- node 10+
|
||||
|
||||
## Gettings started
|
||||
|
||||
npm install
|
||||
npm run start
|
||||
|
||||
# TODOs
|
||||
|
||||
- use `ID`-type for unique identifiers instead of `Int` (detect UUID)
|
||||
- add example responses to resolvers.mustache
|
||||
- support for union types
|
@ -0,0 +1,97 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# Version: 1.0.0
|
||||
#
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
|
||||
# package openapi3graphql-server
|
||||
|
||||
# pet_api
|
||||
|
||||
|
||||
|
||||
input AddPetInput {
|
||||
# Pet object that needs to be added to the store
|
||||
pet: PetInput
|
||||
}
|
||||
|
||||
input DeletePetInput {
|
||||
# Pet id to delete
|
||||
petId: Int!,
|
||||
|
||||
apiKey: String!
|
||||
}
|
||||
|
||||
input UpdatePetInput {
|
||||
# Pet object that needs to be added to the store
|
||||
pet: PetInput
|
||||
}
|
||||
|
||||
input UpdatePetWithFormInput {
|
||||
# ID of pet that needs to be updated
|
||||
petId: Int!,
|
||||
# Updated name of the pet
|
||||
name: String!,
|
||||
# Updated status of the pet
|
||||
status: String!
|
||||
}
|
||||
|
||||
input UploadFileInput {
|
||||
# ID of pet to update
|
||||
petId: Int!,
|
||||
# Additional data to pass to server
|
||||
additionalMetadata: String!,
|
||||
# file to upload
|
||||
file: String!
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
# Add a new pet to the store
|
||||
# @param Pet pet Pet object that needs to be added to the store
|
||||
# @return [Boolean]
|
||||
AddPet(input: AddPetInput!): Boolean
|
||||
# Deletes a pet
|
||||
# @param Int! petId Pet id to delete
|
||||
# @param String! apiKey
|
||||
# @return [Boolean]
|
||||
DeletePet(input: DeletePetInput!): Boolean
|
||||
# Update an existing pet
|
||||
# @param Pet pet Pet object that needs to be added to the store
|
||||
# @return [Boolean]
|
||||
UpdatePet(input: UpdatePetInput!): Boolean
|
||||
# Updates a pet in the store with form data
|
||||
# @param Int! petId ID of pet that needs to be updated
|
||||
# @param String! name Updated name of the pet
|
||||
# @param String! status Updated status of the pet
|
||||
# @return [Boolean]
|
||||
UpdatePetWithForm(input: UpdatePetWithFormInput!): Boolean
|
||||
# uploads an image
|
||||
# @param Int! petId ID of pet to update
|
||||
# @param String! additionalMetadata Additional data to pass to server
|
||||
# @param String! file file to upload
|
||||
# @return [ApiResponse]
|
||||
UploadFile(input: UploadFileInput!): ApiResponse
|
||||
}
|
||||
|
||||
type Query {
|
||||
# Finds Pets by status
|
||||
# Multiple status values can be provided with comma separated strings
|
||||
# @param String! status Status values that need to be considered for filter
|
||||
# @return [Pet]
|
||||
FindPetsByStatus(status: String!): Pet
|
||||
# Finds Pets by tags
|
||||
# Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
# @param String! tags Tags to filter by
|
||||
# @return [Pet]
|
||||
FindPetsByTags(tags: String!): Pet
|
||||
# Find pet by ID
|
||||
# Returns a single pet
|
||||
# @param Int! petId ID of pet to return
|
||||
# @return [Pet]
|
||||
GetPetById(petId: Int!): Pet
|
||||
}
|
||||
|
@ -0,0 +1,86 @@
|
||||
/**
|
||||
*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* Version: 1.0.0
|
||||
*
|
||||
* Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
// package openapi3graphql-server
|
||||
|
||||
// pet_api
|
||||
|
||||
export default {
|
||||
Query: {
|
||||
|
||||
// @return Pet
|
||||
FindPetsByStatus: ($status) => {
|
||||
return {
|
||||
"status": ""
|
||||
};
|
||||
},
|
||||
|
||||
// @return Pet
|
||||
FindPetsByTags: ($tags) => {
|
||||
return {
|
||||
"tags": ""
|
||||
};
|
||||
},
|
||||
|
||||
// @return Pet
|
||||
GetPetById: ($petId) => {
|
||||
return {
|
||||
"petId": "789"
|
||||
};
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
Mutation: {
|
||||
|
||||
// @return
|
||||
AddPet: ($pet) => {
|
||||
return {
|
||||
"pet": ""
|
||||
};
|
||||
},
|
||||
|
||||
// @return
|
||||
DeletePet: ($petId, $apiKey) => {
|
||||
return {
|
||||
"petId": "789",
|
||||
"apiKey": "apiKey_example"
|
||||
};
|
||||
},
|
||||
|
||||
// @return
|
||||
UpdatePet: ($pet) => {
|
||||
return {
|
||||
"pet": ""
|
||||
};
|
||||
},
|
||||
|
||||
// @return
|
||||
UpdatePetWithForm: ($petId, $name, $status) => {
|
||||
return {
|
||||
"petId": "789",
|
||||
"name": "name_example",
|
||||
"status": "status_example"
|
||||
};
|
||||
},
|
||||
|
||||
// @return ApiResponse
|
||||
UploadFile: ($petId, $additionalMetadata, $file) => {
|
||||
return {
|
||||
"petId": "789",
|
||||
"additionalMetadata": "additionalMetadata_example",
|
||||
"file": "BINARY_DATA_HERE"
|
||||
};
|
||||
},
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# Version: 1.0.0
|
||||
#
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
|
||||
# package openapi3graphql-server
|
||||
|
||||
# store_api
|
||||
|
||||
|
||||
|
||||
input DeleteOrderInput {
|
||||
# ID of the order that needs to be deleted
|
||||
orderId: String!
|
||||
}
|
||||
|
||||
input PlaceOrderInput {
|
||||
# order placed for purchasing the pet
|
||||
order: OrderInput
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
# Delete purchase order by ID
|
||||
# For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
# @param String! orderId ID of the order that needs to be deleted
|
||||
# @return [Boolean]
|
||||
DeleteOrder(input: DeleteOrderInput!): Boolean
|
||||
# Place an order for a pet
|
||||
# @param Order order order placed for purchasing the pet
|
||||
# @return [Order]
|
||||
PlaceOrder(input: PlaceOrderInput!): Order
|
||||
}
|
||||
|
||||
type Query {
|
||||
# Returns pet inventories by status
|
||||
# Returns a map of status codes to quantities
|
||||
# @return [Int!]
|
||||
GetInventory: Int!
|
||||
# Find purchase order by ID
|
||||
# For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
# @param Int! orderId ID of pet that needs to be fetched
|
||||
# @return [Order]
|
||||
GetOrderById(orderId: Int!): Order
|
||||
}
|
||||
|
@ -0,0 +1,53 @@
|
||||
/**
|
||||
*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* Version: 1.0.0
|
||||
*
|
||||
* Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
// package openapi3graphql-server
|
||||
|
||||
// store_api
|
||||
|
||||
export default {
|
||||
Query: {
|
||||
|
||||
// @return Int!
|
||||
GetInventory: () => {
|
||||
return {
|
||||
|
||||
};
|
||||
},
|
||||
|
||||
// @return Order
|
||||
GetOrderById: ($orderId) => {
|
||||
return {
|
||||
"orderId": "789"
|
||||
};
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
Mutation: {
|
||||
|
||||
// @return
|
||||
DeleteOrder: ($orderId) => {
|
||||
return {
|
||||
"orderId": "orderId_example"
|
||||
};
|
||||
},
|
||||
|
||||
// @return Order
|
||||
PlaceOrder: ($order) => {
|
||||
return {
|
||||
"order": ""
|
||||
};
|
||||
},
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# Version: 1.0.0
|
||||
#
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
|
||||
# package openapi3graphql-server
|
||||
|
||||
# user_api
|
||||
|
||||
|
||||
|
||||
input CreateUserInput {
|
||||
# Created user object
|
||||
user: UserInput
|
||||
}
|
||||
|
||||
input CreateUsersWithArrayInputInput {
|
||||
# List of user object
|
||||
user: [UserInput]
|
||||
}
|
||||
|
||||
input CreateUsersWithListInputInput {
|
||||
# List of user object
|
||||
user: [UserInput]
|
||||
}
|
||||
|
||||
input DeleteUserInput {
|
||||
# The name that needs to be deleted
|
||||
username: String!
|
||||
}
|
||||
|
||||
input UpdateUserInput {
|
||||
# name that need to be deleted
|
||||
username: String!,
|
||||
# Updated user object
|
||||
user: UserInput
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
# Create user
|
||||
# This can only be done by the logged in user.
|
||||
# @param User user Created user object
|
||||
# @return [Boolean]
|
||||
CreateUser(input: CreateUserInput!): Boolean
|
||||
# Creates list of users with given input array
|
||||
# @param User user List of user object
|
||||
# @return [Boolean]
|
||||
CreateUsersWithArrayInput(input: CreateUsersWithArrayInputInput!): Boolean
|
||||
# Creates list of users with given input array
|
||||
# @param User user List of user object
|
||||
# @return [Boolean]
|
||||
CreateUsersWithListInput(input: CreateUsersWithListInputInput!): Boolean
|
||||
# Delete user
|
||||
# This can only be done by the logged in user.
|
||||
# @param String! username The name that needs to be deleted
|
||||
# @return [Boolean]
|
||||
DeleteUser(input: DeleteUserInput!): Boolean
|
||||
# Updated user
|
||||
# This can only be done by the logged in user.
|
||||
# @param String! username name that need to be deleted
|
||||
# @param User user Updated user object
|
||||
# @return [Boolean]
|
||||
UpdateUser(input: UpdateUserInput!): Boolean
|
||||
}
|
||||
|
||||
type Query {
|
||||
# Get user by user name
|
||||
# @param String! username The name that needs to be fetched. Use user1 for testing.
|
||||
# @return [User]
|
||||
GetUserByName(username: String!): User
|
||||
# Logs user into the system
|
||||
# @param String! username The user name for login
|
||||
# @param String! password The password for login in clear text
|
||||
# @return [String!]
|
||||
LoginUser(username: String!, password: String!): String!
|
||||
# Logs out current logged in user session
|
||||
# @return [Boolean]
|
||||
LogoutUser: Boolean
|
||||
}
|
||||
|
@ -0,0 +1,83 @@
|
||||
/**
|
||||
*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* Version: 1.0.0
|
||||
*
|
||||
* Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
// package openapi3graphql-server
|
||||
|
||||
// user_api
|
||||
|
||||
export default {
|
||||
Query: {
|
||||
|
||||
// @return User
|
||||
GetUserByName: ($username) => {
|
||||
return {
|
||||
"username": "username_example"
|
||||
};
|
||||
},
|
||||
|
||||
// @return String!
|
||||
LoginUser: ($username, $password) => {
|
||||
return {
|
||||
"username": "username_example",
|
||||
"password": "password_example"
|
||||
};
|
||||
},
|
||||
|
||||
// @return
|
||||
LogoutUser: () => {
|
||||
return {
|
||||
|
||||
};
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
Mutation: {
|
||||
|
||||
// @return
|
||||
CreateUser: ($user) => {
|
||||
return {
|
||||
"user": ""
|
||||
};
|
||||
},
|
||||
|
||||
// @return
|
||||
CreateUsersWithArrayInput: ($user) => {
|
||||
return {
|
||||
"user": ""
|
||||
};
|
||||
},
|
||||
|
||||
// @return
|
||||
CreateUsersWithListInput: ($user) => {
|
||||
return {
|
||||
"user": ""
|
||||
};
|
||||
},
|
||||
|
||||
// @return
|
||||
DeleteUser: ($username) => {
|
||||
return {
|
||||
"username": "username_example"
|
||||
};
|
||||
},
|
||||
|
||||
// @return
|
||||
UpdateUser: ($username, $user) => {
|
||||
return {
|
||||
"username": "username_example",
|
||||
"user": ""
|
||||
};
|
||||
},
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# Version: 1.0.0
|
||||
#
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
|
||||
# Describes the result of uploading an image resource
|
||||
type ApiResponse {
|
||||
code: Int!
|
||||
type: String!
|
||||
message: String!
|
||||
}
|
||||
|
||||
input ApiResponseInput {
|
||||
code: Int!
|
||||
type: String!
|
||||
message: String!
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# Version: 1.0.0
|
||||
#
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
|
||||
# A category for a pet
|
||||
type Category {
|
||||
id: Int!
|
||||
name: String!
|
||||
}
|
||||
|
||||
input CategoryInput {
|
||||
id: Int!
|
||||
name: String!
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# Version: 1.0.0
|
||||
#
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
|
||||
type InlineObject {
|
||||
# Updated name of the pet
|
||||
name: String!
|
||||
# Updated status of the pet
|
||||
status: String!
|
||||
}
|
||||
|
||||
input InlineObjectInput {
|
||||
# Updated name of the pet
|
||||
name: String!
|
||||
# Updated status of the pet
|
||||
status: String!
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# Version: 1.0.0
|
||||
#
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
|
||||
type InlineObject1 {
|
||||
# Additional data to pass to server
|
||||
additionalMetadata: String!
|
||||
# file to upload
|
||||
file: String!
|
||||
}
|
||||
|
||||
input InlineObject1Input {
|
||||
# Additional data to pass to server
|
||||
additionalMetadata: String!
|
||||
# file to upload
|
||||
file: String!
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# Version: 1.0.0
|
||||
#
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
|
||||
# An order for a pets from the pet store
|
||||
type Order {
|
||||
id: Int!
|
||||
petId: Int!
|
||||
quantity: Int!
|
||||
shipDate: String!
|
||||
# Order Status
|
||||
status: OrderStatusEnum
|
||||
complete: Boolean!
|
||||
}
|
||||
|
||||
input OrderInput {
|
||||
id: Int!
|
||||
petId: Int!
|
||||
quantity: Int!
|
||||
shipDate: String!
|
||||
# Order Status
|
||||
status: OrderStatusEnum
|
||||
complete: Boolean!
|
||||
}
|
||||
|
||||
# Order Status
|
||||
enum OrderStatusEnum {
|
||||
placed
|
||||
approved
|
||||
delivered
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# Version: 1.0.0
|
||||
#
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
|
||||
# A pet for sale in the pet store
|
||||
type Pet {
|
||||
id: Int!
|
||||
category: Category
|
||||
name: String!
|
||||
photoUrls: String!
|
||||
tags: Tag
|
||||
# pet status in the store
|
||||
status: PetStatusEnum
|
||||
}
|
||||
|
||||
input PetInput {
|
||||
id: Int!
|
||||
category: CategoryInput
|
||||
name: String!
|
||||
photoUrls: [String!]
|
||||
tags: [TagInput]
|
||||
# pet status in the store
|
||||
status: PetStatusEnum
|
||||
}
|
||||
|
||||
# pet status in the store
|
||||
enum PetStatusEnum {
|
||||
available
|
||||
pending
|
||||
sold
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# Version: 1.0.0
|
||||
#
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
|
||||
# A tag for a pet
|
||||
type Tag {
|
||||
id: Int!
|
||||
name: String!
|
||||
}
|
||||
|
||||
input TagInput {
|
||||
id: Int!
|
||||
name: String!
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# Version: 1.0.0
|
||||
#
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
|
||||
# A User who is purchasing from the pet store
|
||||
type User {
|
||||
id: Int!
|
||||
username: String!
|
||||
firstName: String!
|
||||
lastName: String!
|
||||
email: String!
|
||||
password: String!
|
||||
phone: String!
|
||||
# User Status
|
||||
userStatus: Int!
|
||||
}
|
||||
|
||||
input UserInput {
|
||||
id: Int!
|
||||
username: String!
|
||||
firstName: String!
|
||||
lastName: String!
|
||||
email: String!
|
||||
password: String!
|
||||
phone: String!
|
||||
# User Status
|
||||
userStatus: Int!
|
||||
}
|
2123
samples/server/petstore/graphql-server/openapi3graphql-server/package-lock.json
generated
Normal file
2123
samples/server/petstore/graphql-server/openapi3graphql-server/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "graphql-server",
|
||||
"version": "1.0.0",
|
||||
"description": " This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. ",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "node start.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"express": "latest",
|
||||
"graphql": "latest",
|
||||
"apollo-server-express": "latest",
|
||||
"graphql-combine": "latest",
|
||||
"lodash": "latest",
|
||||
"path": "latest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-register": "latest",
|
||||
"babel-preset-env": "latest"
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
interface Entity {
|
||||
id: Int!
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
import express from 'express';
|
||||
import {ApolloServer, graphiqlExpress, graphqlExpress} from 'apollo-server-express'
|
||||
import combine from 'graphql-combine'
|
||||
import path from 'path'
|
||||
|
||||
const PORT = 4000 || process.env;
|
||||
|
||||
// Initialize the app
|
||||
const app = express();
|
||||
|
||||
// Get combined typeDefs and resolvers object
|
||||
const {typeDefs, resolvers} = combine({
|
||||
// TypeDefs glob pattern
|
||||
typeDefs: path.join(__dirname, '**/*.graphql'),
|
||||
|
||||
// Resolvers glob pattern
|
||||
resolvers: path.join(__dirname, 'api/*_resolver.js')
|
||||
});
|
||||
|
||||
// GraphQL: Schema
|
||||
const server = new ApolloServer({
|
||||
typeDefs: typeDefs,
|
||||
resolvers: resolvers,
|
||||
playground: {
|
||||
endpoint: `http://localhost:${PORT}/graphql`,
|
||||
settings: {
|
||||
'editor.theme': 'light'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
server.applyMiddleware({app: app});
|
||||
|
||||
// Start the server
|
||||
app.listen(PORT, () => {
|
||||
console.log(`You can reach GraphQL at: http://localhost:${PORT}/graphql`);
|
||||
});
|
@ -0,0 +1,7 @@
|
||||
// Transpile all code following this line with babel and use 'env' (aka ES6) preset.
|
||||
require('babel-register')({
|
||||
presets: ['env']
|
||||
});
|
||||
|
||||
// Import the rest of our application.
|
||||
module.exports = require('./server.js');
|
8
samples/server/petstore/graphql-server/petstore/.gitignore
vendored
Normal file
8
samples/server/petstore/graphql-server/petstore/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# MacOS
|
||||
.DS_Store
|
||||
|
||||
# IDE
|
||||
/.idea
|
||||
|
||||
# JS specific
|
||||
/node_modules
|
18
samples/server/petstore/graphql-server/petstore/README.md
Normal file
18
samples/server/petstore/graphql-server/petstore/README.md
Normal file
@ -0,0 +1,18 @@
|
||||
# GraphQL express API server
|
||||
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
## Requirements
|
||||
|
||||
- node 10+
|
||||
|
||||
## Gettings started
|
||||
|
||||
npm install
|
||||
npm run start
|
||||
|
||||
# TODOs
|
||||
|
||||
- use `ID`-type for unique identifiers instead of `Int` (detect UUID)
|
||||
- add example responses to resolvers.mustache
|
||||
- support for union types
|
@ -0,0 +1,97 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# Version: 1.0.0
|
||||
#
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
|
||||
# package petstore
|
||||
|
||||
# pet_api
|
||||
|
||||
|
||||
|
||||
input AddPetInput {
|
||||
# Pet object that needs to be added to the store
|
||||
pet: PetInput
|
||||
}
|
||||
|
||||
input DeletePetInput {
|
||||
# Pet id to delete
|
||||
petId: Int!,
|
||||
|
||||
apiKey: String!
|
||||
}
|
||||
|
||||
input UpdatePetInput {
|
||||
# Pet object that needs to be added to the store
|
||||
pet: PetInput
|
||||
}
|
||||
|
||||
input UpdatePetWithFormInput {
|
||||
# ID of pet that needs to be updated
|
||||
petId: Int!,
|
||||
# Updated name of the pet
|
||||
name: String!,
|
||||
# Updated status of the pet
|
||||
status: String!
|
||||
}
|
||||
|
||||
input UploadFileInput {
|
||||
# ID of pet to update
|
||||
petId: Int!,
|
||||
# Additional data to pass to server
|
||||
additionalMetadata: String!,
|
||||
# file to upload
|
||||
file: String!
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
# Add a new pet to the store
|
||||
# @param Pet pet Pet object that needs to be added to the store
|
||||
# @return [Boolean]
|
||||
AddPet(input: AddPetInput!): Boolean
|
||||
# Deletes a pet
|
||||
# @param Int! petId Pet id to delete
|
||||
# @param String! apiKey
|
||||
# @return [Boolean]
|
||||
DeletePet(input: DeletePetInput!): Boolean
|
||||
# Update an existing pet
|
||||
# @param Pet pet Pet object that needs to be added to the store
|
||||
# @return [Boolean]
|
||||
UpdatePet(input: UpdatePetInput!): Boolean
|
||||
# Updates a pet in the store with form data
|
||||
# @param Int! petId ID of pet that needs to be updated
|
||||
# @param String! name Updated name of the pet
|
||||
# @param String! status Updated status of the pet
|
||||
# @return [Boolean]
|
||||
UpdatePetWithForm(input: UpdatePetWithFormInput!): Boolean
|
||||
# uploads an image
|
||||
# @param Int! petId ID of pet to update
|
||||
# @param String! additionalMetadata Additional data to pass to server
|
||||
# @param String! file file to upload
|
||||
# @return [ApiResponse]
|
||||
UploadFile(input: UploadFileInput!): ApiResponse
|
||||
}
|
||||
|
||||
type Query {
|
||||
# Finds Pets by status
|
||||
# Multiple status values can be provided with comma separated strings
|
||||
# @param String! status Status values that need to be considered for filter
|
||||
# @return [Pet]
|
||||
FindPetsByStatus(status: String!): Pet
|
||||
# Finds Pets by tags
|
||||
# Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
# @param String! tags Tags to filter by
|
||||
# @return [Pet]
|
||||
FindPetsByTags(tags: String!): Pet
|
||||
# Find pet by ID
|
||||
# Returns a single pet
|
||||
# @param Int! petId ID of pet to return
|
||||
# @return [Pet]
|
||||
GetPetById(petId: Int!): Pet
|
||||
}
|
||||
|
@ -0,0 +1,86 @@
|
||||
/**
|
||||
*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* Version: 1.0.0
|
||||
*
|
||||
* Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
// package petstore
|
||||
|
||||
// pet_api
|
||||
|
||||
export default {
|
||||
Query: {
|
||||
|
||||
// @return Pet
|
||||
FindPetsByStatus: ($status) => {
|
||||
return {
|
||||
"status": ""
|
||||
};
|
||||
},
|
||||
|
||||
// @return Pet
|
||||
FindPetsByTags: ($tags) => {
|
||||
return {
|
||||
"tags": ""
|
||||
};
|
||||
},
|
||||
|
||||
// @return Pet
|
||||
GetPetById: ($petId) => {
|
||||
return {
|
||||
"petId": "789"
|
||||
};
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
Mutation: {
|
||||
|
||||
// @return
|
||||
AddPet: ($pet) => {
|
||||
return {
|
||||
"pet": ""
|
||||
};
|
||||
},
|
||||
|
||||
// @return
|
||||
DeletePet: ($petId, $apiKey) => {
|
||||
return {
|
||||
"petId": "789",
|
||||
"apiKey": "apiKey_example"
|
||||
};
|
||||
},
|
||||
|
||||
// @return
|
||||
UpdatePet: ($pet) => {
|
||||
return {
|
||||
"pet": ""
|
||||
};
|
||||
},
|
||||
|
||||
// @return
|
||||
UpdatePetWithForm: ($petId, $name, $status) => {
|
||||
return {
|
||||
"petId": "789",
|
||||
"name": "name_example",
|
||||
"status": "status_example"
|
||||
};
|
||||
},
|
||||
|
||||
// @return ApiResponse
|
||||
UploadFile: ($petId, $additionalMetadata, $file) => {
|
||||
return {
|
||||
"petId": "789",
|
||||
"additionalMetadata": "additionalMetadata_example",
|
||||
"file": "BINARY_DATA_HERE"
|
||||
};
|
||||
},
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# Version: 1.0.0
|
||||
#
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
|
||||
# package petstore
|
||||
|
||||
# store_api
|
||||
|
||||
|
||||
|
||||
input DeleteOrderInput {
|
||||
# ID of the order that needs to be deleted
|
||||
orderId: String!
|
||||
}
|
||||
|
||||
input PlaceOrderInput {
|
||||
# order placed for purchasing the pet
|
||||
order: OrderInput
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
# Delete purchase order by ID
|
||||
# For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
# @param String! orderId ID of the order that needs to be deleted
|
||||
# @return [Boolean]
|
||||
DeleteOrder(input: DeleteOrderInput!): Boolean
|
||||
# Place an order for a pet
|
||||
# @param Order order order placed for purchasing the pet
|
||||
# @return [Order]
|
||||
PlaceOrder(input: PlaceOrderInput!): Order
|
||||
}
|
||||
|
||||
type Query {
|
||||
# Returns pet inventories by status
|
||||
# Returns a map of status codes to quantities
|
||||
# @return [Int!]
|
||||
GetInventory: Int!
|
||||
# Find purchase order by ID
|
||||
# For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
# @param Int! orderId ID of pet that needs to be fetched
|
||||
# @return [Order]
|
||||
GetOrderById(orderId: Int!): Order
|
||||
}
|
||||
|
@ -0,0 +1,53 @@
|
||||
/**
|
||||
*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* Version: 1.0.0
|
||||
*
|
||||
* Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
// package petstore
|
||||
|
||||
// store_api
|
||||
|
||||
export default {
|
||||
Query: {
|
||||
|
||||
// @return Int!
|
||||
GetInventory: () => {
|
||||
return {
|
||||
|
||||
};
|
||||
},
|
||||
|
||||
// @return Order
|
||||
GetOrderById: ($orderId) => {
|
||||
return {
|
||||
"orderId": "789"
|
||||
};
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
Mutation: {
|
||||
|
||||
// @return
|
||||
DeleteOrder: ($orderId) => {
|
||||
return {
|
||||
"orderId": "orderId_example"
|
||||
};
|
||||
},
|
||||
|
||||
// @return Order
|
||||
PlaceOrder: ($order) => {
|
||||
return {
|
||||
"order": ""
|
||||
};
|
||||
},
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# Version: 1.0.0
|
||||
#
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
|
||||
# package petstore
|
||||
|
||||
# user_api
|
||||
|
||||
|
||||
|
||||
input CreateUserInput {
|
||||
# Created user object
|
||||
user: UserInput
|
||||
}
|
||||
|
||||
input CreateUsersWithArrayInputInput {
|
||||
# List of user object
|
||||
user: [UserInput]
|
||||
}
|
||||
|
||||
input CreateUsersWithListInputInput {
|
||||
# List of user object
|
||||
user: [UserInput]
|
||||
}
|
||||
|
||||
input DeleteUserInput {
|
||||
# The name that needs to be deleted
|
||||
username: String!
|
||||
}
|
||||
|
||||
input UpdateUserInput {
|
||||
# name that need to be deleted
|
||||
username: String!,
|
||||
# Updated user object
|
||||
user: UserInput
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
# Create user
|
||||
# This can only be done by the logged in user.
|
||||
# @param User user Created user object
|
||||
# @return [Boolean]
|
||||
CreateUser(input: CreateUserInput!): Boolean
|
||||
# Creates list of users with given input array
|
||||
# @param User user List of user object
|
||||
# @return [Boolean]
|
||||
CreateUsersWithArrayInput(input: CreateUsersWithArrayInputInput!): Boolean
|
||||
# Creates list of users with given input array
|
||||
# @param User user List of user object
|
||||
# @return [Boolean]
|
||||
CreateUsersWithListInput(input: CreateUsersWithListInputInput!): Boolean
|
||||
# Delete user
|
||||
# This can only be done by the logged in user.
|
||||
# @param String! username The name that needs to be deleted
|
||||
# @return [Boolean]
|
||||
DeleteUser(input: DeleteUserInput!): Boolean
|
||||
# Updated user
|
||||
# This can only be done by the logged in user.
|
||||
# @param String! username name that need to be deleted
|
||||
# @param User user Updated user object
|
||||
# @return [Boolean]
|
||||
UpdateUser(input: UpdateUserInput!): Boolean
|
||||
}
|
||||
|
||||
type Query {
|
||||
# Get user by user name
|
||||
# @param String! username The name that needs to be fetched. Use user1 for testing.
|
||||
# @return [User]
|
||||
GetUserByName(username: String!): User
|
||||
# Logs user into the system
|
||||
# @param String! username The user name for login
|
||||
# @param String! password The password for login in clear text
|
||||
# @return [String!]
|
||||
LoginUser(username: String!, password: String!): String!
|
||||
# Logs out current logged in user session
|
||||
# @return [Boolean]
|
||||
LogoutUser: Boolean
|
||||
}
|
||||
|
@ -0,0 +1,83 @@
|
||||
/**
|
||||
*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* Version: 1.0.0
|
||||
*
|
||||
* Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
// package petstore
|
||||
|
||||
// user_api
|
||||
|
||||
export default {
|
||||
Query: {
|
||||
|
||||
// @return User
|
||||
GetUserByName: ($username) => {
|
||||
return {
|
||||
"username": "username_example"
|
||||
};
|
||||
},
|
||||
|
||||
// @return String!
|
||||
LoginUser: ($username, $password) => {
|
||||
return {
|
||||
"username": "username_example",
|
||||
"password": "password_example"
|
||||
};
|
||||
},
|
||||
|
||||
// @return
|
||||
LogoutUser: () => {
|
||||
return {
|
||||
|
||||
};
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
Mutation: {
|
||||
|
||||
// @return
|
||||
CreateUser: ($user) => {
|
||||
return {
|
||||
"user": ""
|
||||
};
|
||||
},
|
||||
|
||||
// @return
|
||||
CreateUsersWithArrayInput: ($user) => {
|
||||
return {
|
||||
"user": ""
|
||||
};
|
||||
},
|
||||
|
||||
// @return
|
||||
CreateUsersWithListInput: ($user) => {
|
||||
return {
|
||||
"user": ""
|
||||
};
|
||||
},
|
||||
|
||||
// @return
|
||||
DeleteUser: ($username) => {
|
||||
return {
|
||||
"username": "username_example"
|
||||
};
|
||||
},
|
||||
|
||||
// @return
|
||||
UpdateUser: ($username, $user) => {
|
||||
return {
|
||||
"username": "username_example",
|
||||
"user": ""
|
||||
};
|
||||
},
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# Version: 1.0.0
|
||||
#
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
|
||||
# Describes the result of uploading an image resource
|
||||
type ApiResponse {
|
||||
code: Int!
|
||||
type: String!
|
||||
message: String!
|
||||
}
|
||||
|
||||
input ApiResponseInput {
|
||||
code: Int!
|
||||
type: String!
|
||||
message: String!
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# Version: 1.0.0
|
||||
#
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
|
||||
# A category for a pet
|
||||
type Category {
|
||||
id: Int!
|
||||
name: String!
|
||||
}
|
||||
|
||||
input CategoryInput {
|
||||
id: Int!
|
||||
name: String!
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# Version: 1.0.0
|
||||
#
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
|
||||
# An order for a pets from the pet store
|
||||
type Order {
|
||||
id: Int!
|
||||
petId: Int!
|
||||
quantity: Int!
|
||||
shipDate: String!
|
||||
# Order Status
|
||||
status: OrderStatusEnum
|
||||
complete: Boolean!
|
||||
}
|
||||
|
||||
input OrderInput {
|
||||
id: Int!
|
||||
petId: Int!
|
||||
quantity: Int!
|
||||
shipDate: String!
|
||||
# Order Status
|
||||
status: OrderStatusEnum
|
||||
complete: Boolean!
|
||||
}
|
||||
|
||||
# Order Status
|
||||
enum OrderStatusEnum {
|
||||
placed
|
||||
approved
|
||||
delivered
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# Version: 1.0.0
|
||||
#
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
|
||||
# A pet for sale in the pet store
|
||||
type Pet {
|
||||
id: Int!
|
||||
category: Category
|
||||
name: String!
|
||||
photoUrls: String!
|
||||
tags: Tag
|
||||
# pet status in the store
|
||||
status: PetStatusEnum
|
||||
}
|
||||
|
||||
input PetInput {
|
||||
id: Int!
|
||||
category: CategoryInput
|
||||
name: String!
|
||||
photoUrls: [String!]
|
||||
tags: [TagInput]
|
||||
# pet status in the store
|
||||
status: PetStatusEnum
|
||||
}
|
||||
|
||||
# pet status in the store
|
||||
enum PetStatusEnum {
|
||||
available
|
||||
pending
|
||||
sold
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# Version: 1.0.0
|
||||
#
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
|
||||
# A tag for a pet
|
||||
type Tag {
|
||||
id: Int!
|
||||
name: String!
|
||||
}
|
||||
|
||||
input TagInput {
|
||||
id: Int!
|
||||
name: String!
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# Version: 1.0.0
|
||||
#
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
|
||||
# A User who is purchasing from the pet store
|
||||
type User {
|
||||
id: Int!
|
||||
username: String!
|
||||
firstName: String!
|
||||
lastName: String!
|
||||
email: String!
|
||||
password: String!
|
||||
phone: String!
|
||||
# User Status
|
||||
userStatus: Int!
|
||||
}
|
||||
|
||||
input UserInput {
|
||||
id: Int!
|
||||
username: String!
|
||||
firstName: String!
|
||||
lastName: String!
|
||||
email: String!
|
||||
password: String!
|
||||
phone: String!
|
||||
# User Status
|
||||
userStatus: Int!
|
||||
}
|
25
samples/server/petstore/graphql-server/petstore/package.json
Normal file
25
samples/server/petstore/graphql-server/petstore/package.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "graphql-server",
|
||||
"version": "1.0.0",
|
||||
"description": " This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. ",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "node start.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"express": "latest",
|
||||
"graphql": "latest",
|
||||
"apollo-server-express": "latest",
|
||||
"graphql-combine": "latest",
|
||||
"lodash": "latest",
|
||||
"path": "latest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-register": "latest",
|
||||
"babel-preset-env": "latest"
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
interface Entity {
|
||||
id: Int!
|
||||
}
|
37
samples/server/petstore/graphql-server/petstore/server.js
Normal file
37
samples/server/petstore/graphql-server/petstore/server.js
Normal file
@ -0,0 +1,37 @@
|
||||
import express from 'express';
|
||||
import {ApolloServer, graphiqlExpress, graphqlExpress} from 'apollo-server-express'
|
||||
import combine from 'graphql-combine'
|
||||
import path from 'path'
|
||||
|
||||
const PORT = 4000 || process.env;
|
||||
|
||||
// Initialize the app
|
||||
const app = express();
|
||||
|
||||
// Get combined typeDefs and resolvers object
|
||||
const {typeDefs, resolvers} = combine({
|
||||
// TypeDefs glob pattern
|
||||
typeDefs: path.join(__dirname, '**/*.graphql'),
|
||||
|
||||
// Resolvers glob pattern
|
||||
resolvers: path.join(__dirname, 'api/*_resolver.js')
|
||||
});
|
||||
|
||||
// GraphQL: Schema
|
||||
const server = new ApolloServer({
|
||||
typeDefs: typeDefs,
|
||||
resolvers: resolvers,
|
||||
playground: {
|
||||
endpoint: `http://localhost:${PORT}/graphql`,
|
||||
settings: {
|
||||
'editor.theme': 'light'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
server.applyMiddleware({app: app});
|
||||
|
||||
// Start the server
|
||||
app.listen(PORT, () => {
|
||||
console.log(`You can reach GraphQL at: http://localhost:${PORT}/graphql`);
|
||||
});
|
7
samples/server/petstore/graphql-server/petstore/start.js
Normal file
7
samples/server/petstore/graphql-server/petstore/start.js
Normal file
@ -0,0 +1,7 @@
|
||||
// Transpile all code following this line with babel and use 'env' (aka ES6) preset.
|
||||
require('babel-register')({
|
||||
presets: ['env']
|
||||
});
|
||||
|
||||
// Import the rest of our application.
|
||||
module.exports = require('./server.js');
|
Loading…
Reference in New Issue
Block a user