Skip to content

Commit a63ddbe

Browse files
authored
Dpg and ApiView integration doc (#19122)
1 parent 2dcad6d commit a63ddbe

File tree

20 files changed

+622
-0
lines changed

20 files changed

+622
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Add Autorest Configuration of .Net SDK
2+
3+
## Parameter Description
4+
5+
- `<ServiceName>`: The RP name, which is usually same as folder name in swagger.
6+
- `<NameSpace>`: Python package name.
7+
- `<Title>`: SDK Client Name. It's optional if there is a title defined in spec readme.md file.
8+
9+
## Autorest Configuration
10+
Please copy the following configuration into spec PR comment.
11+
~~~
12+
# azure-sdk-for-net-track2
13+
``` yaml
14+
title: <Title>
15+
output-folder: sdk/<ServiceName>/<NameSpace>
16+
require:
17+
- specification/<RPName>/data-plane/readme.md
18+
```
19+
~~~
20+
- `title`: If it's already defined in spec readme.md, you don't need to define it here again. (By default, there is no `title` defined in spec readme.md in multi client scenario.)
21+
- `output-folder`: The relative path of destination to generate SDK.
22+
- `require`: The item of the value is the relative path of spec readme.md file.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Integrate DPG and ApiView in SDK Automation Pipeline
2+
This document is targeting for everyone who wants to know all the implementation details of SDK automation pipeline.
3+
It describes the details of integrating DPG and ApiView in SDK Automation Pipeline.
4+
5+
Before go through this document, please go through [Service Onboard DPG with Swagger CI Pipeline](README.md) to be familiar with the user experience in service team side. Also, you need to be familiar with [SDK Automation Pipeline Framework](../sdkautomation/README.md).
6+
7+
# WorkFlow
8+
![integrate-dpg-and-apiview](imgs/integrate-dpg-and-apiview.png)
9+
10+
__Description:__
11+
1. SDK Automation Pipeline is triggered in spec PR CI.
12+
2. SDK Automation Pipeline Framework checks whether there is a comment containing autorest configuration in spec PR. If found, generate sdk by the autorest configuration in comment.
13+
Otherwise, sdk automation pipeline will try to find if there is autorest configuration file in sdk repo. If found, generate sdk with the founded autorest configuration file. If not found, pipeline stops.
14+
1. When there is a comment containing autorest configuration, sdk automation pipeline will extract the autorest configuration from the comment, and let automation script use it to generate a new autorest configuration file, and use the new generated autorest configuration file to generate SDK.
15+
1. We need to make the comment as simple as possible. Currently, the common fields needed by all sdk are `output-folder` and `require` keyword.
16+
2. When getting the comment, automation script needs to parse it to extract needed information, and then use the extracted information to generate autorest configuration file in sdk repository.
17+
3. The value of `output-folder` is a relative path from sdk root folder. It is mainly used to extract information, such as service name, package name. In generating autorest configuration file in sdk repository, please replace it to the correct value.
18+
4. The value of `require` is a relative path to readme.md from spec root folder. In generating autorest configuration file in sdk repository, please concat relative path from package folder to sdk repo and `specFolder` in `generateInput.json`. For example:
19+
```yaml
20+
require:
21+
- ../../../../../azure-rest-api-specs/specification/deviceupdate/data-plane/readme.md
22+
```
23+
*You can also use the absolute path of spec repo, which can be resolved by yourself.*
24+
5. If there is other metadata in autorest configuration of spec PR comment, please copy them to autorest configuration file directly. (Although we only list little metadata service team can use in spec PR comment, we still need to support to add more metadata because the metadata listed in document maybe not enough.)
25+
2. When using the autorest configuration file found in sdk repository to generate SDK, SDK automation script need to modify the autorest configuration file in the SDK repo.
26+
1. If `require` block is used, change the `require` block to include the latest swagger `readme.md` in the PR.
27+
2. `input-file` will not be used. If the existing autorest configuration file uses `input-file`, we should change it to `require` before triggering the sdk automation pipeline, or add the autorest configuration in spec comment.
28+
3. After generating SDK, SDK automation pipeline generates ApiView and then add comments about results to the Swagger PR.
29+
30+
# Future Work
31+
Currently, we ask service team must add a comment containing autorest configuration in spec PR when new service onboards DPG.
32+
In the future, we are going to integrate it with PowerAPP Workflow. Then service team can provide the necessary information in PowerAPP Workflow, and the information will be added to spec PR automatically.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Service Onboard DPG with Swagger CI Pipeline
2+
3+
Service Onboarding DPG with Swagger CI pipeline can help you get generated SDK and ApiView during the procedure of creating swagger PR.
4+
The benefits are following:
5+
1. API signature could be reviewed at the same time when we submit a Swagger PR. This could help to detect API issues at the early stage.
6+
2. It enables service teams to access their SDKs even before their Swagger PR is merged.
7+
8+
This Document describes the process of how to onboard DPG with SDK automation pipeline. __This document is targeting for service team, who wants to onboard DPG.__
9+
10+
*If you want to go through details of pipeline implementation, please go to [Integrate DPG and ApiView in SDK Automation Pipeline](Integrate-dpg-and-apiview-in-sdk-automation-pipeline.md).*
11+
12+
## WorkFlow
13+
14+
![workflow-for-service-team](imgs/workflow-service-team.png)
15+
16+
__Description:__
17+
1. Creates a swagger PR with [Guide to design and creation of Data Plane REST API and Client Libraries](https://aka.ms/azsdk/dpcodegen).
18+
2. If you have added a comment, which contains autorest configuration, and run `/azp run` in the spec PR, the autorest configuration in the comment will be used to generate SDK.
19+
Otherwise, pipeline will try to find autorest configuration file in sdk repository. If found, use the autorest configuration file to generate SDK. If not found, pipeline will stop.
20+
- Please refer to [Add autorest configuration in spec comment](./add-autorest-configuration-for-dataplane-sdk.md) on how to add autorest configuration in spec comment.
21+
3. SDK and ApiView will be generated in spec CI pipeline, and you can find them in spec PR comment. Please refer to the [Guide of Reviewing the Api Design/Definition](https://dev.azure.com/azure-sdk/internal/_wiki/wikis/internal.wiki/591/Guide-to-design-and-creation-of-Data-Plane-REST-API-and-Client-Libraries?anchor=ii.-review-the-api-design/definition) to review the API definition.
22+
4. If any change needed, please update the autorest configuration in spec PR comment and regenerate the SDK by adding a comment `/azp run` to swagger PR.
23+
24+
## FAQ
25+
26+
1. Where can I find the generated sdk and corresponding ApiView?
27+
28+
__Answer__: You can find them in spec PR comment. The generated SDK can be found in comment `Swagger Generation Artifacts`, and the corresponding ApiView Link can be found in comment `Generated ApiView`. Following screenshots comes from [example PR](https://github.com/Azure/azure-rest-api-specs/pull/20017)
29+
30+
![](./imgs/example_generated_sdk.png)
31+
![](./imgs/example_generated_apiview.png)
32+
33+
3. What should I do when I encounter error in generating SDK in swagger PR CI pipeline?
34+
35+
__Answer__: Please check the comment [Swagger Generation Artifacts] and the error message of failed pipeline. If you find the error messages ask you to fix autorest configuration comment or swagger, please fix it. If you cannot understand error message, please ask sdk owners for help with mail: [email protected].
36+
37+
4. What should I do when it creates ApiView Failed?
38+
39+
__Answer__: If the ApiView is created failed, you can find there is an error message: `Create ApiView failed. Please ensure your github account in Azure/Microsoft is public and re-trigger the CI. If issue still exists, please ask PR assignee for help`. If you want to get the ApiView,
40+
please follow the action in error message, and make you github account's organization information public, then re-trigger the CI (You can re-trigger CI by comment `/azp run`, or close and reopen the PR). If it still cannot generate ApiView, please ask PR assignee for help.
41+
42+
5. Is there ApiView generated when there is no sdk generated in sdk automation pipeline?
43+
__Answer__: No. Creating ApiView is based on the generated codes in sdk automation pipeline.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Add Autorest Configuration for Dataplane SDK
2+
3+
## Prerequisites
4+
There should be a basic readme.md together with swagger, and you can refer to the [sample](../samplefiles-dp).
5+
6+
## Add Autorest Configuration for .Net SDK
7+
Please refer to [Add Autorest Configuration for .Net SDK](.net/README.md).
8+
9+
## Add Autorest Configuration for Java SDK
10+
Please refer to [Add Autorest Configuration for Java SDK](java/README.md).
11+
12+
## Add Autorest Configuration for Python SDK
13+
Please refer to [Add Autorest Configuration for Python SDK](python/README.md).
14+
15+
## Add Autorest Configuration for JS SDK
16+
Please refer to [Add Autorest Configuration for JS SDK](js/README.md).
75.9 KB
Loading
108 KB
Loading
84.9 KB
Loading
80 KB
Loading
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Add Autorest Configuration of Java SDK
2+
3+
## Parameter Description
4+
5+
- `<ServiceName>`: The RP name, which is usually same as rp name in swagger.
6+
- `<PackageName>`: Java package name.
7+
- `<Namespace>`: It should start with `com.`, and the remaining part can be got from `<PackageName>` by replacing `- with `.'. For example, if `<PackageName>` is `azure-analytics-purview-administration`, then `<Namespace>` is `com.azure.analytics.purview.administration`.
8+
9+
10+
## Single Client
11+
If you want to generate sdk with single client, please copy the following configuration into spec PR comment.
12+
~~~
13+
# azure-sdk-for-java
14+
``` yaml
15+
output-folder: sdk/<ServiceName>/<PackageName>
16+
namespace: <Namespace>
17+
data-plane: true
18+
require:
19+
- specification/<RPName>/data-plane/readme.md
20+
```
21+
~~~
22+
- `namespace`: The namespace of generated sdk.
23+
- `output-folder`: The relative path of destination to generate SDK.
24+
- `require`: The item of the value is the relative path of spec readme.md file.
25+
26+
## Multi Client
27+
If you want to generate sdk with multi client, please copy the following configuration into spec PR comment.
28+
~~~
29+
# azure-sdk-for-java
30+
``` yaml
31+
tag: false
32+
output-folder: sdk/<ServiceName>/<PackageName>
33+
namespace: <Namespace>
34+
data-plane: true
35+
require:
36+
- specification/<ServiceName>/data-plane/readme.md
37+
batch:
38+
- package-A: true
39+
- package-B: true
40+
```
41+
~~~
42+
- `namespace`: The namespace of generated sdk.
43+
- `output-folder`: The relative path of destination to generate SDK.
44+
- `require`: The item of the value is the relative path of spec readme.md file.
45+
- `package-A` and `package-B` must be defined in swagger `readme.md` file. For samples, please refer to [dataplane samples for multi client](../../samplefiles-dp/samplefiles-dp-for-multi-client).
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Add Autorest Configuration of JS SDK
2+
3+
## Parameter Description
4+
5+
- `<ServiceName>`: The RP name, which is usually same as folder name in swagger.
6+
- `<PackageFolder>`: Python package folder name, which must ends with `-rest`. For example: `purview-administration-rest`.
7+
- `<SubFolderName>`: The sub-folder name in the package. It's only used by multi-client scenario.
8+
9+
## Single Client
10+
If you want to generate sdk with single client, please copy the following configuration into spec PR comment.
11+
~~~
12+
# azure-sdk-for-js
13+
``` yaml
14+
output-folder: sdk/<ServiceName>/<PackageFolder>
15+
require:
16+
- specification/<ServiceName>/data-plane/readme.md
17+
```
18+
~~~
19+
- `output-folder`: The relative path of destination to generate SDK.
20+
- `require`: The item of the value is the relative path of spec readme.md file.
21+
22+
## Multi Client
23+
If you want to generate sdk with multi client, please copy the following configuration into spec PR comment.
24+
~~~
25+
# azure-sdk-for-js
26+
``` yaml $(multi-client)
27+
tag: false
28+
require:
29+
- specification/<RPName>/data-plane/readme.md
30+
batch:
31+
- package-A: true
32+
- package-B: true
33+
```
34+
35+
``` yaml $(package-A)
36+
output-folder: sdk/<ServiceName>/<PackageFolder>/src/<SubFolderName>
37+
```
38+
39+
``` yaml $(package-B)
40+
output-folder: sdk/<ServiceName>/<PackageFolder>/src/<SubFolderName>
41+
```
42+
~~~
43+
- `output-folder`: The relative path of destination to generate SDK.
44+
- `require`: The item of the value is the relative path of spec readme.md file.
45+
- `package-A` and `package-B` must be defined in swagger `readme.md` file. For samples, please refer to [dataplane samples for multi client](../../samplefiles-dp/samplefiles-dp-for-multi-client).

0 commit comments

Comments
 (0)