Skip to content
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

Merged
merged 33 commits into from
Feb 12, 2025
Merged
Changes from 6 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9f7f5f4
Add the introduction of emitters for sdk clients.
lirenhe Jan 20, 2025
bb53d7d
add python emitter doc
msyyc Jan 21, 2025
ff9fc0d
java part
weidongxu-microsoft Jan 24, 2025
c7622ce
Merge branch 'main' into introduction-sdk-client-emitters
markcowl Jan 24, 2025
b780da9
Update the JavaScript emitter information
MaryGao Jan 24, 2025
b55dcce
refactor the content
lirenhe Jan 26, 2025
ff3a26e
add doc on Java emitter required depencencies
weidongxu-microsoft Jan 26, 2025
9ba0e86
Add note for Python client emitter.
msyyc Jan 26, 2025
f2c4dfe
Merge branch 'main' into introduction-sdk-client-emitters
lirenhe Jan 26, 2025
469c96a
Update the content of introduction.md
lirenhe Jan 26, 2025
d77ab16
Merge branch 'main' into introduction-sdk-client-emitters
lirenhe Feb 5, 2025
47db420
Merge branch 'main' into introduction-sdk-client-emitters
lirenhe Feb 8, 2025
625ddb4
Update the content based on the feedback.
lirenhe Feb 8, 2025
15d942a
Merge branch 'main' into introduction-sdk-client-emitters
lirenhe Feb 8, 2025
199426f
fix a type for display icon
lirenhe Feb 8, 2025
1f7a7a2
Update the format
lirenhe Feb 8, 2025
da71388
fix build error
lirenhe Feb 8, 2025
56992b1
Remove steps which would cause the build error.
lirenhe Feb 10, 2025
021de38
Update the sidebar
lirenhe Feb 10, 2025
0664619
Merge branch 'main' into introduction-sdk-client-emitters
lirenhe Feb 10, 2025
cd1db4d
Fix format issue.
lirenhe Feb 10, 2025
a431a92
Merge branch 'introduction-sdk-client-emitters' of https://github.com…
lirenhe Feb 10, 2025
bda5d43
Update the reference content
lirenhe Feb 10, 2025
6830ec2
Add steps to better format the text
lirenhe Feb 11, 2025
2f4d315
Merge branch 'main' into introduction-sdk-client-emitters
lirenhe Feb 11, 2025
7011a36
Update format
lirenhe Feb 11, 2025
ed05423
Merge branch 'introduction-sdk-client-emitters' of https://github.com…
lirenhe Feb 11, 2025
c6a191c
Merge branch 'main' into introduction-sdk-client-emitters
lmazuel Feb 12, 2025
9ead927
Update the content to use HTTP clients instead and refine some wording.
lirenhe Feb 12, 2025
5970145
Merge branch 'main' into introduction-sdk-client-emitters
lirenhe Feb 12, 2025
ffa0d48
Update the content
lirenhe Feb 12, 2025
33f068e
Merge branch 'introduction-sdk-client-emitters' of https://github.com…
lirenhe Feb 12, 2025
4876ada
Merge branch 'main' into introduction-sdk-client-emitters
timotheeguerin Feb 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions website/src/content/docs/docs/emitters/sdk-clients/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
---
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.

| **Emitter Name** | **Language** | **Version** | **Common Configuration** |
| ---------------------------- | ------------ | ------------------------ | ------------------------ |
| @azure-tools/typespec-ts | JavaScript | `0.38.1` | `emitter-output-dir` |
| @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-server-javascript": "^0.58.0-alpha.6",
"@typespec/http-client-java": "^0.1.9",
"@typespec/http-client-python": "^0.6.6",
"@azure-tools/typespec-ts": "^0.37.0",
}
```

#### Note: Check for the Latest Version

To ensure you are using the latest version of the packages, visit npmjs.com and search for the relevant packages.

## Language-Specific Settings

### JavaScript Client Emitter

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

### Java Client Emitter

No additional setting needed for Java.

### .NET Client Emitter

## 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

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"
"@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.

Run the following command:

```bash
tsp install
```

2. 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 .
```

## 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.