-
Notifications
You must be signed in to change notification settings - Fork 238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the introduction of emitters for sdk clients. #5663
base: main
Are you sure you want to change the base?
Changes from all commits
9f7f5f4
bb53d7d
ff9fc0d
c7622ce
b780da9
b55dcce
ff3a26e
9ba0e86
f2c4dfe
469c96a
d77ab16
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
--- | ||
title: introduction of SDK client emitters | ||
--- | ||
|
||
## How to Use Client Emitters to Generate SDK from TypeSpec | ||
|
||
### Introduction | ||
|
||
This guide will walk you through the process of using different client emitters (JavaScript, Python, Java, .NET) to generate SDKs from TypeSpec. Please note that all client emitters are currently in **preview** and are subject to changes in future versions. | ||
|
||
By following this guide, you will learn: | ||
|
||
1. How to set up and configure client emitters. | ||
2. Update the client emitter configurations in `package.json` and `tspconfig.yaml`. | ||
3. How to run the SDK generation for each specific programming language. | ||
|
||
## Location of All Client Emitters and Common Configurations | ||
|
||
The client emitters and their common configurations are located in the `package.json` file within your project. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. configuration is in the |
||
|
||
| **Emitter Name** | **Language** | **Version** | **Common Configuration** | | ||
| ---------------------------- | ------------ | ------------------------ | ------------------------ | | ||
| @azure-tools/typespec-ts | JavaScript | `0.38.1` | `emitter-output-dir` | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure also what common configuration means here |
||
| @typespec/http-client-python | Python | `0.6.6` | `emitter-output-dir` | | ||
| @typespec/http-client-java | Java | `0.1.9` | `emitter-output-dir` | | ||
| @typespec/http-client-csharp | .NET | `0.1.9-alpha.20250113.2` | `emitter-output-dir` | | ||
|
||
### Common Configuration Options | ||
|
||
- `emitter-output-dir`: Defines where the generated SDK files will be stored. | ||
|
||
Below is an example of the `package.json` snippet where client emitters are defined: | ||
|
||
```json | ||
"dependencies": { | ||
"@typespec/http-client-csharp": "^0.1.9-alpha.20250113.2", | ||
"@typespec/http-client-java": "^0.1.9", | ||
"@typespec/http-client-python": "^0.6.6", | ||
"@azure-tools/typespec-ts": "^0.38.1", | ||
} | ||
``` | ||
|
||
#### Note: Check for the Latest Version | ||
|
||
To ensure you are using the latest version of the packages, visit [npmjs](https://www.npmjs.com/) and search for the relevant packages. | ||
|
||
## Language-Specific Settings | ||
|
||
### JavaScript Client Emitter | ||
|
||
lirenhe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Generally no additional setting is required for JavaScript. However it's recommended to specify `packageDetails` which would provide package metadata in `package.json` and `README.md` files. | ||
|
||
#### packageDetails | ||
|
||
Provide the metadata for `package.json`, `README.md` information. | ||
|
||
| Property | Description | | ||
| ----------- | ---------------------------------------------------------------------- | | ||
| name | Package name used in `package.json` | | ||
| description | Package description used in `package.json` file | | ||
| version | Detailed version for your package, the default value is `1.0.0-beta.1` | | ||
|
||
Example configuration: | ||
|
||
```yaml | ||
packageDetails: | ||
name: "${your_package_name}" | ||
version: 1.0.0 | ||
``` | ||
|
||
### Python Client Emitter | ||
|
||
msyyc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
No additional setting needed for Python. | ||
|
||
### Java Client Emitter | ||
|
||
#### Required Dependencies | ||
|
||
Java (Java Development Kit) and Maven (Apache Maven) is required to be installed, before running Java client emitter. | ||
|
||
The required version and the URL for downloading is specified below: | ||
|
||
- [Java](https://docs.microsoft.com/java/openjdk/download) 17 or above. (Verify by running `java --version`) | ||
- [Maven](https://maven.apache.org/download.cgi). (Verify by running `mvn --version`) | ||
|
||
#### Configuration Options for Java | ||
|
||
No additional setting needed for Java. | ||
|
||
### .NET Client Emitter | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the goal of this section to list the available options or to list additional required options? If no languages have any other required options, is there any reason to retain each language option section? If the goal is to list all the additional options, then there are several other options for .NET. https://github.com/microsoft/typespec/blob/main/packages/http-client-csharp/emitter/src/options.ts#L10-L26 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah +1, not sure what the point is of this section, we shouldn't have any required option to start. |
||
|
||
## Running Language-Specific Emitters in CLI | ||
|
||
1. Ensure that your package.json file is correctly configured to include the necessary dependencies for running the emitters | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can use starlight steps to hav ea nicely presented stepped tutorial https://starlight.astro.build/components/steps/ |
||
|
||
1. Update the tspconfig.yaml file for properly configured for the language-specific emitter. | ||
|
||
```yaml | ||
emit: | ||
- "@typespec/http-client-csharp" | ||
- "@typespec/http-client-java" | ||
- "@typespec/http-client-python" | ||
- "@azure-tools/typespec-ts" | ||
options: | ||
"@typespec/http-client-csharp": | ||
emitter-output-dir: "{project-root}/../clients/dotnet" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are the path going |
||
"@typespec/http-client-java": | ||
emitter-output-dir: "{project-root}/../clients/java" | ||
"@typespec/http-client-python": | ||
emitter-output-dir: "{project-root}/../clients/python" | ||
"@azure-tools/typespec-ts": | ||
emitter-output-dir: "{project-root}/../clients/javascript" | ||
packageDetails: | ||
name: "${your_package_name}" | ||
version: 1.0.0 | ||
``` | ||
|
||
1. Once the package.json and tspconfig.yaml files are updated, you need to install all required dependencies. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we include instructions for installing the dependencies? |
||
|
||
Run the following command: | ||
|
||
```bash | ||
tsp install | ||
``` | ||
|
||
1. Run the emitter to compile your TypeScript code into the desired language. Use the following command to trigger the emitter and compile your project: | ||
|
||
```bash | ||
tsp compile . | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we clarify that this will only work if |
||
``` | ||
|
||
## Disclaimer | ||
|
||
> **All client emitters are in preview**. These emitters are actively being developed and may experience changes or updates that could affect their functionality. Please follow the official documentation for the latest updates. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we link to the official documentation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would be good that we include it right there on the website as well(in the same way we have docs for the other emitters) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use asides for notes/warning, etc. https://starlight.astro.build/components/asides/ :::note |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This page is not showing on the website. Make sure it is included in the sidebar