@azure-tools/typespec-python 0.44.2 → 0.45.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,118 +1,139 @@
1
- # TypeSpec Python Client Emitter
1
+ # @azure-tools/typespec-python
2
2
 
3
- ## Getting started
3
+ TypeSpec emitter for Python SDKs
4
4
 
5
- ### Initialize TypeSpec Project
5
+ ## Install
6
6
 
7
- Follow [TypeSpec Getting Started](https://typespec.io/docs) to initialize your TypeSpec project.
7
+ ```bash
8
+ npm install @azure-tools/typespec-python
9
+ ```
10
+
11
+ ## Usage
8
12
 
9
- Make sure `npx tsp compile .` runs correctly.
13
+ 1. Via the command line
10
14
 
11
- ### Add typespec-python to your project
15
+ ```bash
16
+ tsp compile . --emit=@azure-tools/typespec-python
17
+ ```
12
18
 
13
- Include @azure-tools/typespec-python dependencies in `package.json`:
19
+ 2. Via the config
14
20
 
15
- ```diff
16
- "dependencies": {
17
- + "@azure-tools/typespec-python": "latest"
18
- },
21
+ ```yaml
22
+ emit:
23
+ - "@azure-tools/typespec-python"
19
24
  ```
20
25
 
21
- Run `npm install` to install the dependency.
26
+ The config can be extended with options as follows:
22
27
 
23
- ### Generate a Python client library
28
+ ```yaml
29
+ emit:
30
+ - "@azure-tools/typespec-python"
31
+ options:
32
+ "@azure-tools/typespec-python":
33
+ option: value
34
+ ```
24
35
 
25
- You can either specify typespec-python on the commandline or through tspconfig.yaml.
36
+ ## Emitter options
26
37
 
27
- #### Generate with `--emit` command
38
+ ### `emitter-output-dir`
28
39
 
29
- Run command `npx tsp compile --emit @azure-tools/typespec-python <path-to-typespec-file>`
40
+ **Type:** `absolutePath`
30
41
 
31
- e.g.
42
+ Defines the emitter output directory. Defaults to `{output-dir}/@azure-tools/typespec-python`
43
+ See [Configuring output directory for more info](https://typespec.io/docs/handbook/configuration/configuration/#configuring-output-directory)
32
44
 
33
- ```cmd
34
- npx tsp compile main.tsp --emit @azure-tools/typespec-python
35
- ```
45
+ ### `examples-dir`
36
46
 
37
- or
47
+ **Type:** `string`
38
48
 
39
- ```cmd
40
- npx tsp compile client.tsp --emit @azure-tools/typespec-python
41
- ```
49
+ Specifies the directory where the emitter will look for example files. If the flag isn’t set, the emitter defaults to using an `examples` directory located at the project root.
42
50
 
43
- #### Generate with tspconfig.yaml
51
+ ### `namespace`
44
52
 
45
- Add the following configuration in tspconfig.yaml:
53
+ **Type:** `string`
46
54
 
47
- ```diff
48
- emit:
49
- - "@azure-tools/typespec-python"
50
- options:
51
- "@azure-tools/typespec-python":
52
- + package-dir: "azure-contoso"
53
- + package-name: "azure-contoso"
54
- ```
55
+ Specifies the namespace you want to override for namespaces set in the spec. With this config, all namespace for the spec types will default to it.
55
56
 
56
- Run the command to generate your library:
57
+ ### `flavor`
57
58
 
58
- ```cmd
59
- npx tsp compile main.tsp
60
- ```
59
+ **Type:** `string`
61
60
 
62
- or
61
+ The flavor of the SDK.
63
62
 
64
- ```cmd
65
- npx tsp compile client.tsp
66
- ```
63
+ ### `models-mode`
67
64
 
68
- ## Configure the generated library
65
+ **Type:** `"dpg" | "none"`
69
66
 
70
- You can further configure the generated client library using the emitter options provided through @azure-tools/typespec-python.
67
+ What kind of models to generate. If you pass in `none`, we won't generate models. `dpg` models are the default models we generate.
71
68
 
72
- You can set options in the command line directly via `--option @azure-tools/typespec-python.<optionName>=XXX`, e.g. `--option @azure-tools/typespec-python.package-name="azure-contoso"`
69
+ ### `generate-sample`
73
70
 
74
- or
71
+ **Type:** `boolean`
75
72
 
76
- Modify `tspconfig.yaml` in the TypeSpec project to add emitter options under options/@azure-tools/typespec-python.
73
+ Whether to generate sample files, for basic samples of your generated sdks. Defaults to `false`.
77
74
 
78
- ```diff
79
- emit:
80
- - "@azure-tools/typespec-python"
81
- options:
82
- "@azure-tools/typespec-python":
83
- + package-dir: "{package-dir}"
84
- + package-name: "azure-contoso"
85
- ```
75
+ ### `generate-test`
86
76
 
87
- ### Supported emitter options
77
+ **Type:** `boolean`
88
78
 
89
- Common emitter configuration example:
79
+ Whether to generate test files, for basic testing of your generated sdks. Defaults to `false`.
90
80
 
91
- ```yaml
92
- emit:
93
- - "@azure-tools/typespec-python"
94
- options:
95
- "@azure-tools/typespec-python":
96
- package-dir: "{package-dir}"
97
- package-name: "azure-contoso"
98
- ```
81
+ ### `api-version`
82
+
83
+ **Type:** `string`
84
+
85
+ Use this flag if you would like to generate the sdk only for a specific version. Default value is the latest version. Also accepts values `latest` and `all`.
86
+
87
+ ### `license`
88
+
89
+ **Type:** `object`
90
+
91
+ License information for the generated client code.
92
+
93
+ ### `package-version`
94
+
95
+ **Type:** `string`
96
+
97
+ The version of the package.
98
+
99
+ ### `package-name`
100
+
101
+ **Type:** `string`
102
+
103
+ The name of the package.
104
+
105
+ ### `generate-packaging-files`
106
+
107
+ **Type:** `boolean`
108
+
109
+ Whether to generate packaging files. Packaging files refer to the `setup.py`, `README`, and other files that are needed to package your code.
110
+
111
+ ### `packaging-files-dir`
112
+
113
+ **Type:** `string`
114
+
115
+ If you are using a custom packaging files directory, you can specify it here. We won't generate with the default packaging files we have.
116
+
117
+ ### `packaging-files-config`
118
+
119
+ **Type:** `object`
120
+
121
+ If you are using a custom packaging files directory, and have additional configuration parameters you want to pass in during generation, you can specify it here. Only applicable if `packaging-files-dir` is set.
122
+
123
+ ### `package-pprint-name`
124
+
125
+ **Type:** `string`
126
+
127
+ The name of the package to be used in pretty-printing. Will be the name of the package in `README` and pprinting of `setup.py`.
128
+
129
+ ### `head-as-boolean`
130
+
131
+ **Type:** `boolean`
132
+
133
+ Whether to return responses from HEAD requests as boolean. Defaults to `true`.
134
+
135
+ ### `use-pyodide`
136
+
137
+ **Type:** `boolean`
99
138
 
100
- |Option|Type|Description|
101
- |-|-|-|
102
- |`package-version`|string|Specify the package version. Default version: `1.0.0b1`.|
103
- |`package-name`|string|Specify the package name.|
104
- |`package-dir`|string|Specify the output directory for the package.|
105
- |`generate-packaging-files`|boolean|Indicate if packaging files, such as setup.py, should be generated.|
106
- |`package-pprint-name`|string|Specify the pretty print name for the package.|
107
- |`flavor`|string|Represents the type of SDK that will be generated. By default, there will be no branding in the generated client library. Specify `"azure"` to generate an SDK following Azure guidelines.|
108
- |`company-name`|string|Specify the company name to be inserted into licensing data. For `"azure"` flavor, the default value inserted is `Microsoft`.|
109
-
110
- **Advanced emitter options**
111
-
112
- |Option|Type|Description|
113
- |-|-|-|
114
- |`head-as-boolean`|boolean|Generate head calls to return a boolean. Default: `true`.|
115
- |`packaging-files-dir`|string|Pass in the path to a custom directory with SDK packaging files.|
116
- |`packaging-files-config`|object|Specify configuration options that will be passed directly into the packaging files specified by the `packaging-files-dir` option.|
117
- |`tracing`|boolean|Only available for the `"azure"` flavor of SDKs, provide tracing support in the generated client library. Default: `true`.|
118
- |`debug`|boolean|Enable debugging.|
139
+ Whether to generate using `pyodide` instead of `python`. If there is no python installed on your device, we will default to using pyodide to generate the code.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-tools/typespec-python",
3
- "version": "0.44.2",
3
+ "version": "0.45.1",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec emitter for Python SDKs",
6
6
  "homepage": "https://github.com/Azure/autorest.python",
@@ -19,8 +19,10 @@
19
19
  "type": "module",
20
20
  "main": "dist/src/index.js",
21
21
  "exports": {
22
- ".": "./dist/src/index.js",
23
- "./testing": "./dist/src/testing/index.js"
22
+ ".": {
23
+ "types": "./dist/src/index.d.ts",
24
+ "default": "./dist/src/index.js"
25
+ }
24
26
  },
25
27
  "tspMain": "dist/src/index.js",
26
28
  "engines": {
@@ -52,27 +54,28 @@
52
54
  "js-yaml": "~4.1.0",
53
55
  "semver": "~7.6.2",
54
56
  "tsx": "~4.19.1",
55
- "@typespec/http-client-python": "~0.11.3",
57
+ "@typespec/http-client-python": "~0.12.1",
56
58
  "fs-extra": "~11.2.0"
57
59
  },
58
60
  "devDependencies": {
59
- "@typespec/compiler": "^1.0.0",
60
- "@typespec/http": "^1.0.0",
61
- "@typespec/rest": "~0.70.0",
62
- "@typespec/versioning": "~0.70.0",
63
- "@typespec/openapi": "^1.0.0",
64
- "@typespec/events": "~0.70.0",
65
- "@typespec/sse": "~0.70.0",
66
- "@typespec/streams": "~0.70.0",
67
- "@typespec/xml": "~0.70.0",
68
- "@azure-tools/typespec-azure-resource-manager": "~0.56.0",
69
- "@azure-tools/typespec-azure-core": "~0.56.0",
70
- "@azure-tools/typespec-azure-rulesets": "~0.56.0",
71
- "@azure-tools/typespec-autorest": "~0.56.0",
72
- "@azure-tools/typespec-client-generator-core": "~0.56.1",
73
- "@azure-tools/azure-http-specs": "0.1.0-alpha.17",
74
- "@typespec/http-specs": "0.1.0-alpha.22",
75
- "@typespec/spector": "0.1.0-alpha.13",
61
+ "@typespec/compiler": "^1.1.0",
62
+ "@typespec/http": "^1.1.0",
63
+ "@typespec/rest": "~0.71.0",
64
+ "@typespec/versioning": "~0.71.0",
65
+ "@typespec/openapi": "^1.1.0",
66
+ "@typespec/events": "~0.71.0",
67
+ "@typespec/sse": "~0.71.0",
68
+ "@typespec/streams": "~0.71.0",
69
+ "@typespec/tspd": "~0.70.0",
70
+ "@typespec/xml": "~0.71.0",
71
+ "@azure-tools/typespec-azure-resource-manager": "~0.57.0",
72
+ "@azure-tools/typespec-azure-core": "~0.57.0",
73
+ "@azure-tools/typespec-azure-rulesets": "~0.57.0",
74
+ "@azure-tools/typespec-autorest": "~0.57.0",
75
+ "@azure-tools/typespec-client-generator-core": "~0.57.0",
76
+ "@azure-tools/azure-http-specs": "0.1.0-alpha.19",
77
+ "@typespec/http-specs": "0.1.0-alpha.23",
78
+ "@typespec/spector": "0.1.0-alpha.15",
76
79
  "@typespec/spec-api": "0.1.0-alpha.6",
77
80
  "@types/js-yaml": "~4.0.5",
78
81
  "@types/node": "~22.13.14",
@@ -96,6 +99,7 @@
96
99
  "lint:fix": "eslint . --fix --ext .ts",
97
100
  "format": "npx prettier **/*.ts --write && tsx ./scripts/eng/format.ts",
98
101
  "regenerate": "tsx ./scripts/eng/regenerate.ts",
99
- "test": "tsx ./scripts/eng/run-tests.ts"
102
+ "test": "tsx ./scripts/eng/run-tests.ts",
103
+ "regen-docs": "npm run build && tspd doc . --enable-experimental --output-dir ./website/src/content/docs/docs/emitters/clients/typespec-python/reference --skip-js"
100
104
  }
101
105
  }