-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Json2code: full $ref support #2452
base: master
Are you sure you want to change the base?
Conversation
abeca0c
to
d7a8500
Compare
Swagger only allows to refer to custom composite types via "$ref", not via "type", whether it is about array elements or individual items. Disallowing "type" would break existing use, so allow "$ref" to be used interchangeably. Signed-off-by: Alexey Bashtanov <[email protected]>
d7a8500
to
0548195
Compare
Swagger needs "$ref", while seastar only allows "type" (at least until scylladb/seastar#2452 is merged), so let's use both for now
@amnonh hi Amnon, could you take a look at this change as well? i plan to review it in this week. |
try: | ||
type = getitem(properties[var], "type", name + ":" + var) | ||
except Exception as e: | ||
try: | ||
type = getitem(properties[var], "$ref", name + ":" + var) | ||
except: | ||
raise e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if $ref
is the notation supported by swagger spec, probably we should check if first. and i'd suggest just use dict.get()
. simpler this way. and we might want to define a tiny helper to avoid the repeating. like:
def get_referenced_type(schema, key)
# to be backward compatible, support "type" as well
type = schema.get("$ref") or schema.get("type")
if type is None:
raise KeyError("$ref")
return type
also, would be better to use the imperative mood in the title of commit message, in this case, could use something like:
|
Swagger only allows to refer to custom composite types via "$ref", not via "type", whether it is about array elements or individual items.
Disallowing "type" would break existing use, so allow "$ref" to be used interchangeably.