Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

update the openapi generator #1

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion openapi/java.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ popd > /dev/null
source "${SCRIPT_ROOT}/openapi-generator/client-generator.sh"
source "${SETTING_FILE}"

OPENAPI_GENERATOR_COMMIT="${OPENAPI_GENERATOR_COMMIT:-v4.0.0}" \
OPENAPI_GENERATOR_USER_ORG="${OPENAPI_GENERATOR_USER_ORG:-fabiokung}" \
OPENAPI_GENERATOR_COMMIT="${OPENAPI_GENERATOR_COMMIT:-mapping-ref-string}" \
CLIENT_LANGUAGE=java; \
CLEANUP_DIRS=(docs src/test/java/io/kubernetes/client/apis src/main/java/io/kubernetes/client/apis src/main/java/io/kubernetes/client/models src/main/java/io/kubernetes/client/auth gradle); \
kubeclient::generator::generate_client "${OUTPUT_DIR}"
4 changes: 2 additions & 2 deletions openapi/java.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
<useRxJava>false</useRxJava>
<library>okhttp-gson</library>
<useReflectionEqualsHashCode>true</useReflectionEqualsHashCode>
<type-mappings>intstr.IntOrString=IntOrString,resource.Quantity=Quantity</type-mappings>
<import-mappings>IntOrString=io.kubernetes.client.custom.IntOrString,Quantity=io.kubernetes.client.custom.Quantity</import-mappings>
</configOptions>
<typeMappings>int-or-string=IntOrString,quantity=Quantity</typeMappings>
<importMappings>IntOrString=io.kubernetes.client.custom.IntOrString,Quantity=io.kubernetes.client.custom.Quantity</importMappings>
<output>${generator.output.path}</output>
</configuration>
</execution>
Expand Down
16 changes: 15 additions & 1 deletion openapi/preprocess_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

from __future__ import print_function

import argparse
import json
import operator
import os.path
import sys
import argparse
from collections import OrderedDict

import urllib3
Expand Down Expand Up @@ -136,6 +136,8 @@ def process_swagger(spec, client_language):

inline_primitive_models(spec, preserved_primitives_for_language(client_language))

add_custom_formatting(spec, format_for_language(client_language))

remove_models(spec, removed_models_for_language(client_language))

return spec
Expand All @@ -150,6 +152,12 @@ def preserved_primitives_for_language(client_language):
else:
return []

def format_for_language(client_language):
if client_language == "java":
return {"resource.Quantity": "quantity"}
else:
return {}

def removed_models_for_language(client_language):
if client_language == "haskell-http-client":
return ["intstr.IntOrString", "resource.Quantity"]
Expand Down Expand Up @@ -298,6 +306,12 @@ def inline_primitive_models(spec, excluded_primitives):
for k in to_remove_models:
del spec['definitions'][k]

def add_custom_formatting(spec, custom_formats):
for k, v in spec['definitions'].items():
if k not in custom_formats:
continue
v["format"] = custom_formats[k]

def write_json(filename, object):
with open(filename, 'w') as out:
json.dump(object, out, sort_keys=False, indent=2, separators=(',', ': '), ensure_ascii=True)
Expand Down