[http/openapi] Use enum-driven visibility analysis APIs#5416
[http/openapi] Use enum-driven visibility analysis APIs#5416witemple-msft merged 33 commits intomicrosoft:mainfrom
Conversation
…e/parameter visibility decorator metadata.
.chronus/changes/witemple-msft-http-visibility-enum-2024-11-19-13-8-4.md
Outdated
Show resolved
Hide resolved
|
All changed packages have been documented.
Show changes
|
|
You can try these changes here
|
…um' into witemple-msft/http-visibility-enum
markcowl
left a comment
There was a problem hiding this comment.
Also, one question: should we change the @parameterVisibility and @returnTypeVisibility decorators to accept enum visibility (or have I missed this being done previously?). Should we be clear that these are any filters?
Also, does @parameterVisibility() now effectively create an undefined any filter, meaning that all properties are allowed?
|
@markcowl I can clarify that returnType/parameter visibility are specifying Good question on |
d8bdb42 to
942b0a1
Compare
Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
This PR brings the core enum-driven visibility system to parity with the existing visibility concepts and uses its new analysis methods in the HTTP and OpenAPI libraries.
DeleteandQueryphases.Deleteapplies when a resource is passed as an argument to a DELETE operation.Queryapplies when a resource is passed as an argument to a GET or HEAD operation.anyconstraint of the filter to be satisfied if it is missing OR if some modifier in the constraint is present. If theanyconstraint is present, but empty, it will be unsatisfiable.getParameterVisibilityandgetReturnTypeVisibilityin favor ofgetParameterVisibilityFilterandgetReturnTypeVisibilityFilterwhich return VisibilityFilter objects instead ofstring[]. Like the modifier analysis methods, the filter versions of these methods are infallible.getParameterVisibilityFilterandgetReturnTypeVisibilityFilteraccept aVisibilityProviderobject that provides default visibility filters for parameters and return types if the parameter/returnType visibilities are not set explicitly. TypeSpec core exports anEmptyProviderthat always return filters with no constraints, suitable as a default. HTTP exportsHttpVisibilityProvider, which must be used when working in HTTP, as it provides the HTTP-specific default visibility logic that determines visibility by verb.HttpVisibilityProvidercan be instantiated with either anHttpVerbdirectly, in which case that exact verb will be used;HttpOperationOptions, in which case the verbSelector will be used if present, otherwise the fallback logic will be used; or no argument in which case the fallback logic will always be used. This gives it parity withgetHttpOperation.Visibilitythrough visibility filters instead of visibility string arrays. The HTTP Visibility concept is unchanged.Fixed a bug in http-server-csharp that was surfaced by these changes where a visibility constraint(invalidated by merge)Visibility.Create & Visibility.Updatewas provided, resulting in Visibility.None and properties being made invisible, affecting effective type calculation for anonymous models.hasVisibilityandgetVisibilityForClasswere improperly initializing the visibility state. This didn't affect the new APIs, but it would cause the state of the legacy APIs to be corrupted if visibility is queried from the new APIs before the legacy APIs.Closes #5119
Closes #5120