-
Notifications
You must be signed in to change notification settings - Fork 69
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
allow passing in the MaxArity for the JsonSchemaVisitor #569
Changes from 9 commits
848cad8
1ee1876
296711d
ae94c4d
11ad06b
fe7dd01
046a4f9
90af9d8
30c8e1c
8b2085c
2d9ba19
31a737e
d28ed75
5485d41
be2c463
0c112da
bdcdcbc
7237dd4
f58aacf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,8 +27,9 @@ import smithy4s.schema.SchemaVisitor | |
import smithy4s.schema.CompilationCache | ||
|
||
final case class codecs( | ||
hintMask: HintMask = codecs.defaultHintMask | ||
) extends JsonCodecAPI(codecs.schemaVisitorJCodec(_), Some(hintMask)) | ||
hintMask: HintMask = codecs.defaultHintMask, | ||
maxArity: Int = codecs.defaultMaxArity | ||
) extends JsonCodecAPI(codecs.schemaVisitorJCodec(_, maxArity), Some(hintMask)) | ||
|
||
object codecs { | ||
|
||
|
@@ -43,13 +44,18 @@ object codecs { | |
// TODO: add tests for `codecs` understanding int enums. Maybe pizza spec | ||
IntEnum | ||
) | ||
val defaultMaxArity: Int = 1024 | ||
|
||
private[smithy4s] def schemaVisitorJCodec( | ||
cache: CompilationCache[JCodec] | ||
cache: CompilationCache[JCodec], | ||
maxArity: Int = defaultMaxArity | ||
): SchemaVisitor[JCodec] = | ||
new SchemaVisitorJCodec(maxArity = 1024, cache) | ||
new SchemaVisitorJCodec(maxArity, cache) | ||
|
||
private[smithy4s] val schemaVisitorJCodec: SchemaVisitor[JCodec] = | ||
new SchemaVisitorJCodec(maxArity = 1024, CompilationCache.nop[JCodec]) | ||
new SchemaVisitorJCodec( | ||
maxArity = defaultMaxArity, | ||
CompilationCache.nop[JCodec] | ||
) | ||
Comment on lines
+56
to
+59
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this version currently used for? From a quick look it seems like only in tests. Maybe we can remove. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Im not sure what you mean by version? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
good point There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yeah sorry that is super confusing! I meant the "Val" vs the "def" above. The val I'm not sure is used anywhere. Thought we could remove it if that is in fact the case. |
||
|
||
} |
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.
the method ought to go on the class, not the object.
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.
I thought it a bit odd to be on the class ,being that the class has a maxArity parameter in the constructor.
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.
Yeah, that's the "fluent builder" pattern. Each
withMethod
is basically equivalent to acopy
modifying just one field, but has the quality of being much more nicer wrt bincompat.The point of having the method on the class is that we can add more methods later on if we need to amend the builder to carry more customisation.