Allow @route decorator to act as a prefix instead of override when ising the operation definition
#9559
Replies: 2 comments
-
|
I figured I can do something like this: Which is kinda of a workaround, and creates inconsistency in path control IMHO, so I'd say still would be very nice to have some more control over hierarchy strings concatenation. REST lib tries to achieve something like I'm trying to describe, but it does it of course on premise of RESTfulness and resources, while this segment I think is actually a good very specific thing path control. |
Beta Was this translation helpful? Give feedback.
-
|
@timotheeguerin Turn this into a discussion |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Clear and concise description of the problem
https://typespec.io/playground/?e=%40typespec%2Fopenapi3&c=aW1wb3J0ICJAdHlwZXNwZWMvaHR0cCI7CtIZb3BlbmFwaSI7Cgp1c2luZyBIdHRwO8cMT3BlbkFQSTsKCgpAcG9zdApAcm91dGUoIi9iYXRjaC9nZXQiKQpvcCDFD0dldDxUPigpOiBUxTLILGNyYWJzzihDxBMgaXPKOXsga2luZDogIsQuIiB9PtVDaW50ZXJmYWNlIMZCewog31TPVH0%3D&options=%7B%7D&vs=%7B%7D
I want to have an operation defining postfix for any operation which implements it.
E.g. root level batchGetCrabs, in my ideal version should result into route
/crabs/batch/get, but rn operation definition level@routeoverrides template@routedecorator, and OAS generated document having just/crabsas a route.I can partially achieve this with the second version, which is wrapping whole thing into Crabs interface or namespace. This creates correct route path, but now suffers from having additional prefix in the operation id. Setting manually
@operationIdnullifying prefixes can be a bit too much just because I have more than a hundred routes then to go through and have to maintain manually. Not impossible, but doesn't make sense.To sum it, result I want to have is operation under
/crabs/batch/getand operationIdbatchGetCrabs.Therefore I see several potential solutions:
@prefix. In this case this decorator can serve many purposes, as general use prefixing decorator which can be used in any place of a hierarchy to indicate that when assembling this part should not override, but be present on a certain level. E.g. in my case I can use it for both cases: for root I'll be using something like@prefix("/crabs", route), which says use/crabsas a prefix for any underlying route decorator; for interface case@prefix(null, operationId)- use nothing as an operationId override for this interface.@operationIdto be set on interfaces and namespace and accept null, in order to completely disable this part of hierarchy from affecting final operationId string.Checklist
Beta Was this translation helpful? Give feedback.
All reactions