Skip to content
Closed
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
10 changes: 8 additions & 2 deletions openapi2jsonschema/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ def default(output, schema, prefix, stand_alone, kubernetes, strict):

info("Generating individual schemas")
for title in data['definitions']:
group = title.split('.')[-3].lower()
version = title.split('.')[-2].lower()

Choose a reason for hiding this comment

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

This will need to be called something else as version now reflects swagger/openapi version.

I just changed my fork of this to use api_version and it works well

kind = title.split('.')[-1].lower()
specification = data['definitions'][title]
specification["$schema"] ="http://json-schema.org/schema#"
Expand All @@ -159,7 +161,7 @@ def default(output, schema, prefix, stand_alone, kubernetes, strict):
types.append(title)

try:
debug("Processing %s" % kind)
debug("Processing %s, %s" % (kind, version))

updated = change_dict_values(specification, prefix)
specification = updated
Expand Down Expand Up @@ -187,7 +189,11 @@ def default(output, schema, prefix, stand_alone, kubernetes, strict):
updated = allow_null_optional_fields(updated)
specification["properties"] = updated

schema_file_name = "%s.json" % kind
if group == "api":
schema_file_name = "%s-%s.json" % (kind, version)
else:
schema_file_name = "%s-%s-%s.json" % (kind, group, version)

with open("%s/%s" % (output, schema_file_name), 'w') as schema_file:
debug("Generating %s" % schema_file_name)
schema_file.write(json.dumps(specification, indent=2))
Expand Down