Clear and concise description of the problem
After discussion I was asked to open an issue/feature request for the following:
I have a scenario where I would like to be able to configure that a model or some model properties are only included if the correct audience is configured for the compilation. Then, when triggering a compile, allow for options to be configured to enable certain audiences for that compilation.
I have implemented (with help of course) a localized decorator `@audience() to do this but believe that a more fully developed solution that is integrated into the core library would be useful.
My implementation looks like this:
/**
* Applies audience-based filtering to a model, model property or operation. Requested audiences are
* read from the `options.networkcloud.audiences` entry in the active TypeSpec configuration. If no config value
* is provided, no audiences are enabled and all annotated items are removed.
*
* Configuration example:
* options:
* mynamespace:
* audiences:
* values:
* - internal
*
* Usage examples:
* // A model, targeting a single audience
* @audience("internal")
* model InternalModel { ... }
*
* // Targeting multiple audiences
* @audience("internal", "external")
* model InternalOrExternalModel { ... }
*
* // An individual model property
* model SomeModel {
* @audience("internal")
* someProperty: string;
*/
extern dec audience(
target: Union | Model | ModelProperty | Operation,
...audienceTargets: valueof string[]
);
In my case, I want to use the same emitter to produce both an internal (service) and external (user) facing representation of my API - both in terms of an OpenAPI schema, and for a Go SDK.
In discussion, this concept could be adapted so that it has applicability to the model as a whole - reflecting in all emitters but could be designed to apply to only certain emitters, or classes of emitters.
Checklist
Clear and concise description of the problem
After discussion I was asked to open an issue/feature request for the following:
I have a scenario where I would like to be able to configure that a model or some model properties are only included if the correct audience is configured for the compilation. Then, when triggering a compile, allow for options to be configured to enable certain audiences for that compilation.
I have implemented (with help of course) a localized decorator `@audience() to do this but believe that a more fully developed solution that is integrated into the core library would be useful.
My implementation looks like this:
In my case, I want to use the same emitter to produce both an internal (service) and external (user) facing representation of my API - both in terms of an OpenAPI schema, and for a Go SDK.
In discussion, this concept could be adapted so that it has applicability to the model as a whole - reflecting in all emitters but could be designed to apply to only certain emitters, or classes of emitters.
Checklist