It was recommended that DTO defensive development be maintained over time at version endpoints, but itβs hard for me to do without losing what I consider to be one of the useful functionality provided by ServiceStack.
I am currently using ServiceStack v3, but you can upgrade to v4 if necessary.
When implementing my service, I can specify several Get () implementations with different contracts, and ServiceStack displays the data coming in accordingly.
Works:
public object Get(EntityBrowse) { ... }
Also works:
public object Get(Contracts.v1.Entity) { ... } public object Get(Contracts.v2.Entity) { ... }
Does not work:
public object Post(Contracts.v1.Entity) { ... } public object Post(Contracts.v2.Entity) { ... }
This case does not work to such an extent that all POSTs that come through this service are mapped to the v1 contract, although the fields do not match. Even the swagger documents demonstrate the incorrect properties of v1, but the correct summary / notes from v2 DTO.
I would like to have a separate DTO for each major version of this endpoint for several reasons:
Courage . Swagger documents created from a DTO with many fields can be confusing for end users of public APIs. How does the user know which fields are for the version of the endpoint that they want to use? I can document this for each field, but I think itβs easier to show the end user only the fields that they like at that time. Different clients will use v2, not knowing that v1 exists.
Validation ServiceStack provides validators for each type. This is fine, except that if my required DTO fields can change over time, I cannot continue to use the same validator without any special shell. Maybe this is an acceptable loss?
Outdated . After the specified time, v1 will become obsolete. v1 is a legacy endpoint implementation, before version control was implemented, and before there were agreed contracts between objects (for example, using "Name" versus "Name", "TypeId" and "Type"). The development of DTO over time after that seems more reasonable, but while v1 exists, endpoints are limited to decisions that developers made, perhaps a decade ago.
After reading this several times, I think that perhaps I should create separate services to support older functions.
The key differences between the versions of my endpoints are:
- permissions
- field names
- organization and display of fields (for example, deleting nested objects)
- implementation details (e.g. how many results are returned by default)
Should I consider splitting my versions into separate services? Should I load one DTO with all fields and just outline the supported version for each property?
source share