diff --git a/packages/fx-core/templates/plugins/resource/apim/README.md b/packages/fx-core/templates/plugins/resource/apim/README.md index 442258f58f..a5f8e61c67 100644 --- a/packages/fx-core/templates/plugins/resource/apim/README.md +++ b/packages/fx-core/templates/plugins/resource/apim/README.md @@ -50,62 +50,9 @@ In the deployment step, there will be some inputs needed: > Note: This may incur costs in your Azure Subscription if you choose to create a new instance in pervious step. ## Write OpenAPI Document + We support both yaml and json format for the OpenAPI document. You need to follow the [OpenAPI Specification](https://swagger.io/resources/open-api/), author the OpenAPI document and ensure the API schema is aligned with the Azure Functions HTTP trigger implementation. -Update the Open API document under the `openapi` folder. We support both yaml and json format for the Open API document. You need to author the Open API document and ensure the API schema is aligned with the function implementation. For how to generate the Open API document, we have the following recommendations. - -### Recommended way 1: Using npm package swagger-jsdoc - -- Run command: `npm install -g swagger-jsdoc`. -- Annotating source code. Read [more](https://github.com/Surnet/swagger-jsdoc/) about how to use swagger-jsdoc to annotate the source code. Below is a sample annotation. - - API annotation - ```js - /** - * @openapi - * /getUserProfile: - * get: - * summary: Get User Profile - * operationId: get-user-profile - * responses: - * '200': - * $ref: "#/components/responses/getUserProfileResponse" - */ - ``` - - Response annotation - ```js - /** - * @openapi - * components: - * responses: - * getUserProfileResponse: - * description: 200 response - * content: - * application/json: - * schema: - * type: object - * properties: - * receivedHTTPRequestBody: - * type: string - * userInfoMessage: - * type: string - * graphClientMessage: - * type: object - */ - ``` -- Create an OpenAPI definition file `openapi/openapi.definition.json` and input the title and version. Below is a sample definition file. - ```json - { - "openapi": "3.0.1", - "info": { - "title": "{appName}", - "version": "v1" - } - } - ``` -- Run command `swagger-jsdoc -d ./openapi/openapi.definition.json -o ./openapi/openapi.json ./api/getUserProfile/*`. Please change the file path `./api/getUserProfile/*` according to your modification. - -### Recommended way 2: OpenAPI (Swagger) Editor in VS Code. - -Below is a sample swagger file for the default http trigger function. You can copy the content into `./openapi/openapi.json`, follow the [OpenAPI Specification](https://swagger.io/resources/open-api/), and change the content according to your modification (E.g. `/getUserProfile` -> `/$yourFunctionName` ). +Below is a sample swagger file for the default HTTP trigger function. You can copy the content into `./openapi/openapi.json`, and change the content according to your modification (E.g. `/getUserProfile` -> `/$yourFunctionName` ). ```json { @@ -147,6 +94,7 @@ Below is a sample swagger file for the default http trigger function. You can co } } ``` +You can use your favorite tool to generate an OpenAPI document, such as [OpenAPI (Swagger) Editor](https://marketplace.visualstudio.com/items?itemName=42Crunch.vscode-openapi) and [swagger-jsdoc](https://github.com/Surnet/swagger-jsdoc/). ## Documentation