You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now Courier records work nicely as resource models in Naptime, but Courier doesn't support non-primitive resource keys well.
The problem
It seems natural to use records for composite resource keys. For example, suppose we have a repositories.v1 resource with key :organization~:repositoryName. We can define a record:
record RepositoryId {
organization: string
repositoryName: string
}
and make requests like GET /repositories.v1/coursera~courier.
However, if we use this key in another model, it'll be serialized as an object, not as a URL-usable string like "coursera~courier". For example:
record PullRequest {
title: string
repositoryId: RepositoryId
}
because then clients can easily pull out the repositoryId field and construct a repositories.v1 request.
A possible workaround right now is to define all ids as typeref RepositoryId = string, which produces the desired serialization, but requires language-specific coercion to preserve type safety.
Proposed solution
Proposed new syntax:
id RepositoryId {
organization: string
repositoryName: string
}
where id objects are string-serialized when used in other record or id objects, using one of the string codecs Courier already supports.
The text was updated successfully, but these errors were encountered:
Right now Courier
record
s work nicely as resource models in Naptime, but Courier doesn't support non-primitive resource keys well.The problem
It seems natural to use
record
s for composite resource keys. For example, suppose we have arepositories.v1
resource with key:organization~:repositoryName
. We can define arecord
:and make requests like
GET /repositories.v1/coursera~courier
.However, if we use this key in another model, it'll be serialized as an object, not as a URL-usable string like
"coursera~courier"
. For example:may be serialized as:
For client convenience, it'd be nice to have this instead:
because then clients can easily pull out the
repositoryId
field and construct arepositories.v1
request.A possible workaround right now is to define all ids as
typeref RepositoryId = string
, which produces the desired serialization, but requires language-specific coercion to preserve type safety.Proposed solution
Proposed new syntax:
where
id
objects are string-serialized when used in otherrecord
orid
objects, using one of the string codecs Courier already supports.The text was updated successfully, but these errors were encountered: