Add typescript-fetch. (#199)
This commit is contained in:
@@ -214,6 +214,8 @@ def process_swagger(spec, client_language, crd_mode=False):
|
||||
|
||||
inline_primitive_models(spec, preserved_primitives_for_language(client_language))
|
||||
|
||||
remove_bad_descriptions(spec, bad_description_pattern_for_language(client_language))
|
||||
|
||||
if crd_mode:
|
||||
clean_crd_meta(spec)
|
||||
|
||||
@@ -236,6 +238,11 @@ def preserved_primitives_for_language(client_language):
|
||||
else:
|
||||
return []
|
||||
|
||||
def bad_description_pattern_for_language(client_language):
|
||||
if client_language == 'typescript-fetch':
|
||||
return '*/'
|
||||
return None
|
||||
|
||||
def format_for_language(client_language):
|
||||
if client_language == "java":
|
||||
return {"resource.Quantity": "quantity", "v1.Patch": "patch"}
|
||||
@@ -415,6 +422,21 @@ def inline_primitive_models(spec, excluded_primitives):
|
||||
for k in to_remove_models:
|
||||
del spec['definitions'][k]
|
||||
|
||||
def remove_bad_descriptions_recursively(model, pattern):
|
||||
desc = model.get('description', '')
|
||||
if desc.find(pattern) >= 0:
|
||||
model['description'] = ''
|
||||
if 'properties' not in model:
|
||||
return
|
||||
for prop in model['properties'].values():
|
||||
remove_bad_descriptions_recursively(prop, pattern)
|
||||
|
||||
def remove_bad_descriptions(spec, pattern):
|
||||
if not pattern:
|
||||
return
|
||||
for model in spec['definitions'].values():
|
||||
remove_bad_descriptions_recursively(model, pattern)
|
||||
|
||||
def add_custom_formatting(spec, custom_formats):
|
||||
for k, v in spec['definitions'].items():
|
||||
if k not in custom_formats:
|
||||
|
||||
52
openapi/typescript-fetch.sh
Executable file
52
openapi/typescript-fetch.sh
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2015 The Kubernetes Authors.
|
||||
#
|
||||
# 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.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
ARGC=$#
|
||||
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "Usage:"
|
||||
echo " $(basename ${0}) OUTPUT_DIR SETTING_FILE_PATH"
|
||||
echo " Setting file should define KUBERNETES_BRANCH, CLIENT_VERSION, and PACKAGE_NAME"
|
||||
echo " Setting file can define an optional USERNAME if you're working on a fork"
|
||||
echo " Setting file can define an optional REPOSITORY if you're working on a ecosystem project"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
OUTPUT_DIR=$1
|
||||
SETTING_FILE=$2
|
||||
mkdir -p "${OUTPUT_DIR}"
|
||||
|
||||
SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")
|
||||
pushd "${SCRIPT_ROOT}" > /dev/null
|
||||
SCRIPT_ROOT=`pwd`
|
||||
popd > /dev/null
|
||||
|
||||
pushd "${OUTPUT_DIR}" > /dev/null
|
||||
OUTPUT_DIR=`pwd`
|
||||
popd > /dev/null
|
||||
|
||||
source "${SCRIPT_ROOT}/openapi-generator/client-generator.sh"
|
||||
source "${SETTING_FILE}"
|
||||
|
||||
OPENAPI_GENERATOR_COMMIT="${OPENAPI_GENERATOR_COMMIT:-v5.2.0}"; \
|
||||
CLIENT_LANGUAGE=typescript-fetch; \
|
||||
CLEANUP_DIRS=(api model); \
|
||||
kubeclient::generator::generate_client "${OUTPUT_DIR}"
|
||||
41
openapi/typescript-fetch.xml
Normal file
41
openapi/typescript-fetch.xml
Normal file
@@ -0,0 +1,41 @@
|
||||
<project
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>io.kubernetes</groupId>
|
||||
<artifactId>client-typescript-fetch</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
<name>client-typescript-fetch</name>
|
||||
<url>http://kubernetes.io</url>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<version>${openapi-generator-version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<inputSpec>${generator.spec.path}</inputSpec>
|
||||
<skipValidateSpec>true</skipValidateSpec>
|
||||
<generatorName>typescript-fetch</generatorName>
|
||||
<output>${generator.output.path}</output>
|
||||
<configOptions>
|
||||
<sortParamsByRequiredFlag>true</sortParamsByRequiredFlag>
|
||||
<supportsES6>true</supportsES6>
|
||||
<prefixParameterInterfaces>true</prefixParameterInterfaces>
|
||||
<npmName>kubernetes-client-typescript-fetch</npmName>
|
||||
<npmVersion>${generator.client.version}</npmVersion>
|
||||
<modelPropertyNaming>original</modelPropertyNaming>
|
||||
</configOptions>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
Reference in New Issue
Block a user