Skip to content

Instantly share code, notes, and snippets.

@BjRo
Created June 21, 2017 16:15
Show Gist options
  • Save BjRo/adb663affd832770db9a8949e2ecd93e to your computer and use it in GitHub Desktop.
Save BjRo/adb663affd832770db9a8949e2ecd93e to your computer and use it in GitHub Desktop.
XING One DSL example
object Address extends ApiDSL {
val t = ApiObjectType(
"Address",
"A standard container for representing an address",
interfaces(Addressable.t),
fields(
optionalApiField("city", StringType),
optionalApiField("province", StringType),
optionalApiField("street", StringType),
optionalApiField("zip", StringType),
optionalApiField("country", CountryCodesAlpha2.t)
)
)
}
@shishkin
Copy link

Nice! Consider wildcard-importing all the members from ApiDSL instead of inheriting from it. Inheritance in this case might be confusing for users of Address if DSL methods are public.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment