Generate Swagger and TypeSpec in Package
If there is a package that requires both TypeSpec and Swagger Generation, follow these steps
File Organization
- If a package already exists - under the package name (
azure-eventgrid/azure/eventgrid/
) create a folder (_legacy
). - 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