-
Notifications
You must be signed in to change notification settings - Fork 14
Building Customized SDKs with Autorest.Swift
This document is to be used by teams who want to create an SDK that uses Swagger-based generated code as a base layer in conjunction with a hand-written convenience layer. This document assumes all work is publicly available.
You will need to clone the following repos to your machine:
- autorest.swift - this repo, used to generate code.
- azure-sdk-for-ios - the main Azure SDK for Swift repo.
- azure-rest-api-specs - the REST API specs (Swagger) repo.
You will then need to switch to the appropriate branches for each repo:
- autorest.swift: use the latest on the
main
branch - azure-sdk-for-ios: switch to the feature branch for your service (i.e.:
feature/AzureStorageBlob
). If a feature branch doesn't exist, contact the SDK team. - azure-rest-api-specs: if your Swagger is already merged to
main
, use that. Often, the Swagger is a work-in-progress on a feature branch, in which case you'll need to switch to that branch.
Install autorest on your machine.
In the autorest.swift
repo root, run the following:
make build
README File
If you store some of your autorest configuration in a README file with Swift configuration, run the following, updating paths as needed:
autorest <PATH TO README>
--swift
--output-folder=~/<PATH TO azure-sdk-for-ios REPO>/sdk/<NAMESPACE>/<SDK NAME>
--use=~/<PATH to autorest.swift REPO>/
No README File
If you don't have a readme file, run the following command, updating paths as needed:
autorest
--input-file=~/<PATH TO azure-rest-api-specs REPO>/specification/<PATH TO YOUR SWAGGER FILE>
--output-folder=~/<PATH TO azure-sdk-for-ios REPO>/sdk/<NAMESPACE>/<SDK NAME>
--namespace=<SDK NAME>
--use=~/<PATH TO autorest.swift REPO>/
This will generate the SDK inside the azure-sdk-for-ios repo in the correct location.
All generated code can be found under the Sources/Generated
folder. Files and folders not found under this folder, such as any you create or the README.md and Package.swift files that are initially generated, will not be overwritten if you re-run the autorest command.
You MUST NOT modify any code under Sources/Generated
. You may add or update any convenience code outside of this folder. If you feel you do need to modify something under Sources/Generated
, reach out to the SDK team.