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

Using specialized schema subclasses #1165


Copy link

commented Aug 1, 2019

Resolves #1164

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 blast-hardcheese:use-specialized-schema-subtypes-where-possible branch from 15f6cbc to 598e45c Aug 1, 2019


This comment has been minimized.

Copy link
Contributor Author

commented Aug 1, 2019

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

left a comment

@gracekarina gracekarina merged commit 47913eb into swagger-api:master Aug 17, 2019

1 check passed

Jenkins Hey Meat Bag! Your Pull Request Build Passed! 496 tests run, 0 skipped, 0 failed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.