зеркало из
1
0
Форкнуть 0
2 Generate Swagger and TypeSpec in Package
Libba Lawrence редактировал(а) эту страницу 2024-02-07 14:05:35 -08:00

Generate Swagger and TypeSpec in Package

If there is a package that requires both TypeSpec and Swagger Generation, follow these steps

File Organization

  1. If a package already exists - under the package name (azure-eventgrid/azure/eventgrid/) create a folder (_legacy).
  2. If there is existing Swagger Generated code under the package name, move them to the _legacy folder.

Generating Swagger and TypeSpec

Swagger

In order to be able to generate from Swagger in the future, under swagger/autorest.md make sure to update the output-file path is updated to include _legacy.

To generate Typespec:

Under the package-name (azure-eventgrid) add a tsp-location.yaml file. This will specify where to find the TypeSpec files in the azure-rest-api-specs repo

directory: specification/PATH-TO-TSP-FILE
commit: YOUR_COMMIT
repo: Azure/azure-rest-api-specs
cleanup: false`

The next step is to install tsp-client if it isn't already installed. Instructions for that are here.

From the command line in your package folder (../azure-sdk-for-python/sdk/package/package-name/) run tsp-client update to generate code.

Aligning ApiView

To ensure that the Swagger generated code gets included in the package's API in package-name/_patch.py import the legacy code.

from ._legacy import (
EventGridPublisherClient,
SystemEvents,
)

An example beta package can be found here