Skip to content

Conversation

@blast-hardcheese
Copy link
Contributor

Resolves #1164

Motivation:
PrimitiveType contains a full mapping (and constructors!) for built-in tracked schema subtypes. By using this, the Schemas generated by the 2to3 converter will have a similar shape to the native 3.x schemas, permitting more unified structure handling for clients (permitting relying on isInstanceOf exclusively, instead of isInstanceOf as well as getType() == "xyz")

Delegating to fromTypeAndFormat to get a particular instance, then createProperty() to instantiate the particular schema resolves the issue I was running into.

If we can't actually look up the mapping, fall back to the original behaviour.

@blast-hardcheese blast-hardcheese force-pushed the use-specialized-schema-subtypes-where-possible branch from 15f6cbc to 598e45c Compare August 1, 2019 20:29
@blast-hardcheese
Copy link
Contributor Author

I force pushed because I found a fallback case where the base type is recognized by PrimitiveType, but the format was not. I handled this by calling with null as the format, then setFormat on the resulting schema (if it exists) otherwise continuing down the chain to new Schema() with the previous behaviour.

Copy link
Contributor

@gracekarina gracekarina left a comment

Choose a reason for hiding this comment

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

@gracekarina gracekarina merged commit 47913eb into swagger-api:master Aug 17, 2019
@blast-hardcheese blast-hardcheese deleted the use-specialized-schema-subtypes-where-possible branch August 24, 2019 00:39
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.

Swagger v2 converter does not use specialized Schema subclasses

2 participants