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

Add support for IntOrString in Java #30

Merged
merged 5 commits into from
Nov 3, 2017

Conversation

lewisheadden
Copy link
Contributor

@lewisheadden lewisheadden commented Nov 1, 2017

Allows certain languages to opt out of preprocessing away primitive types. This is done in order to allow the spec to be passed to Java containing the intstr.IntOrString type. This allows us to then rebind the type mapping for intstr.IntOrString to a custom class (see PR in java client).

print("Making model `%s` inline as %s..." % (k, v["type"]))
find_replace_ref_recursive(spec, "#/definitions/" + k, v)
to_remove_models.append(k)
if k not in excluded_primitives:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think I'd prefer

if k in excluded_primitives:
    continue
...


for k in to_remove_models:
del spec['definitions'][k]

def write_json(filename, object):
with open(filename, 'w') as out:
json.dump(object, out, sort_keys=False, indent=2,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I don't really love this line breaking, can you get it all on one line?

if len(sys.argv) != 3:
print("Usage:\n\n\tpython preprocess_spec.py kuberneres_branch " \
if len(sys.argv) != 4:
print("Usage:\n\n\tpython preprocess_spec.py client_language kuberneres_branch " \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may as well fix the 'kuberneres_branch' typo while you're in here...

@brendandburns
Copy link
Contributor

This basically LGTM, some small nits.

@mbohlool any thoughts?

@lewisheadden
Copy link
Contributor Author

lewisheadden commented Nov 2, 2017

For some reason in ExtensionsV1beta1RollingUpdateDeployment this does not appear to work (it uses String instead of IntOrString). For every other object that uses intstr.IntOrString in the swagger.json it seems to though. I've dug into this for a while and can't quite work out why. Ironically in AppsV1Beta1RollingUpdateDeployment which has exactly the same swagger.json definition, it does use IntOrString instead of String. I'm not quite sure of remediations here, I just wanted to document it for now.

@mbohlool
Copy link
Contributor

mbohlool commented Nov 3, 2017

/lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants