Skip to content

Commit c94b558

Browse files
authored
Update Cadl sample project (#22229)
* Update Cadl sample project - Move sample project under specification folder - remove project.json file from individual project - Add global project.json file under specifications folder
1 parent 1de0b53 commit c94b558

File tree

18 files changed

+69
-121
lines changed

18 files changed

+69
-121
lines changed

custom-words.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2675,3 +2675,4 @@ interactivequery
26752675
tmpfs
26762676
npipe
26772677
Tmpfs
2678+
widget's

documentation/cadl-sample-project/specification/contosowidgetmanager/Contoso.WidgetManager/package.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

documentation/cadl-structure-guidelines.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ The folder name should correspond to the RP-name, but dropping the leading "Azur
7777

7878
### Packages
7979

80-
All services and service family libraries are modeled as Cadl packages, since you must install supporting librarie for proper tooling support. Per this proposal, all packages defined in the repo would be **unpublished**. Only packages in `cadl-azure` would be published. We will annotate the packages with `"private": true` in the `package.json` file to prevent publishing these to npm.
80+
All services and service family libraries are modeled as Cadl packages, since you must install supporting librarie for proper tooling support. Per this proposal, all packages defined in the repo would be **unpublished**. Only packages in `cadl-azure` would be published.
8181

8282
All packages defined in this repo would use the `@cadl-api-spec` scope and use a lowercased, dashed form of the service namespace (ex: `@cadl-api-spec/azure-storage-blob`).
8383

@@ -86,7 +86,6 @@ All packages defined in this repo would use the `@cadl-api-spec` scope and use a
8686
Each package should have the following minimum structure:
8787

8888
- `cadl-project.yaml`
89-
- `package.json`
9089
- `main.cadl` file
9190
- Supporting `*.cadl` files
9291
- `examples/` folder for example JSON files
@@ -95,11 +94,12 @@ Authors may use folders as desired for organizing cadl files.
9594

9695
Additionally, packages which wish to define custom linter rules or otherwise use TypeScript must place any `*.ts` files under a `src/` folder. Within the `src/` folder, the author may use as many subfolders as desired for organizing code.
9796

98-
To distinguish between folders which define a service, an SDK, or both, one can look to the `cadl-project.yaml` and/or the `package.json`.
97+
To distinguish between folders which define a service, an SDK, or both, one can look to the `cadl-project.yaml`.
9998

10099
- SDKs will take dependencies on the `@azure-tools/cadl-dpg` library, as well as SDK-specific emitters such as `@azure-tools/cadl-python` and configure their options within `cadl-project.yaml` but the emitter version should not be configured within `cadl-project.yaml`, and it should be configured globally in SDK repo instead.
101100
- SDKs _may_ have a sidecar file to customize how the SDK is shaped. Folders that describe service definitions only will not have a sidecar file. _Note: the absence of a sidecar does not mean that a folder does not describe an SDK, but the presence of one means it is an SDK._
102101
- Services will take a dependency on `@azure-tools/autorest` and configure the emitter in `cadl-project.yaml`.
102+
- Services should **not** have a `package.json` directly in the cadl directory as they all should be using the global `package.json` in the root specification folder for installing any dependencies needed.
103103

104104
## Service Family Libraries
105105

@@ -113,7 +113,7 @@ import "../Contoso.WidgetManager.Shared";
113113

114114
While this would permit services from importing any service library described in the specs repo, as a matter of policy we should probably avoid that and have tooling to detect this scenario. Service family libraries **should** use versioning decorators and spec packages should reference them as versioned dependencies. Tooling would need to ensure that changes to service family libraries does not result in unexpected changes to any service version. One way to do this would be to diff the projection of the service versions on the `main` branch against the projection of the service versions that result from the change.
115115

116-
We treat the shared library as a sibling with other packages within the service family. This is similar to what we currently do for services that have a "Shared" package and would allow an arbitrary number of shared packages. A shared library folder should not contain `cadl-project.yaml` and `package.json` as it's not requried to be released. See [Sample Project](#sample-project) for reference.
116+
We treat the shared library as a sibling with other packages within the service family. This is similar to what we currently do for services that have a "Shared" package and would allow an arbitrary number of shared packages. A shared library folder should not contain `cadl-project.yaml` as it's not requried to be released. See [Sample Project](#sample-project) for reference.
117117

118118
```
119119
-> specification
@@ -137,7 +137,7 @@ Here's an example of how Cognitive Services might use multiple shared libraries:
137137
```
138138
## Sample Project
139139

140-
Here's a [cadl-sample-project](./cadl-sample-project) to demonstrate the files and folders supposed to be included when check in to this `azure-rest-api-specs` repository.
140+
Here's a [cadl-sample-project](../specification/contosowidgetmanager) to demonstrate the files and folders supposed to be included when check in to this `azure-rest-api-specs` repository.
141141

142142
# Spec Versioning
143143

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"parameters": {
55
"widgetName": "name1",
66
"api-version": "2022-11-01-preview",
7-
"body": {
7+
"resource": {
88
"manufacturerId": "manufacturer id1",
99
"sharedModel": {
1010
"tag": "tag1",

0 commit comments

Comments
 (0)