update tsp (#2170)
This commit is contained in:
Родитель
a4e26e235f
Коммит
f035d0c205
|
@ -4,12 +4,12 @@
|
|||
|
||||
| Library | Min Version |
|
||||
| ----------------------------------------------------------------------- | ------------- |
|
||||
| `@typespec/compiler` | `0.48.0` |
|
||||
| `@typespec/http` | `0.48.0` |
|
||||
| `@typespec/rest` | `0.48.0` |
|
||||
| `@typespec/versioning` | `0.48.0` |
|
||||
| `@azure-tools/typespec-azure-core` | `0.34.0` |
|
||||
| `@azure-tools/typespec-client-generator-core` | `0.35.0-dev.2`|
|
||||
| `@typespec/compiler` | `0.49.0` |
|
||||
| `@typespec/http` | `0.49.0` |
|
||||
| `@typespec/rest` | `0.49.0` |
|
||||
| `@typespec/versioning` | `0.49.0` |
|
||||
| `@azure-tools/typespec-azure-core` | `0.35.0` |
|
||||
| `@azure-tools/typespec-client-generator-core` | `0.35.0` |
|
||||
| `azure-core` dep of generated code | `1.28.0` |
|
||||
| `isodate` dep of generated code | `0.6.1` |
|
||||
| `msrest` dep of generated code (If generating legacy code) | `0.7.1` |
|
||||
|
|
|
@ -43,12 +43,12 @@
|
|||
"get-autorest-python-path.cjs"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"@azure-tools/typespec-azure-core": ">=0.34.0 <1.0.0",
|
||||
"@azure-tools/typespec-client-generator-core": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvMzEzNzIyMi9hcnRpZmFjdE5hbWUvcGFja2FnZXM1/content?format=file&subPath=%2Fazure-tools-typespec-client-generator-core-0.35.0-pr-3678.20231004.2.tgz",
|
||||
"@typespec/compiler": ">=0.48.0 <1.0.0",
|
||||
"@typespec/http": ">=0.48.0 <1.0.0",
|
||||
"@typespec/rest": ">=0.48.0 <1.0.0",
|
||||
"@typespec/versioning": ">=0.48.0 <1.0.0"
|
||||
"@azure-tools/typespec-azure-core": ">=0.35.0 <1.0.0",
|
||||
"@azure-tools/typespec-client-generator-core": ">=0.35.0 <1.0.0",
|
||||
"@typespec/compiler": ">=0.49.0 <1.0.0",
|
||||
"@typespec/http": ">=0.49.0 <1.0.0",
|
||||
"@typespec/rest": ">=0.49.0 <1.0.0",
|
||||
"@typespec/versioning": ">=0.49.0 <1.0.0"
|
||||
},
|
||||
"dependenciesMeta": {
|
||||
"@azure-tools/typespec-client-generator-core": {
|
||||
|
@ -60,18 +60,17 @@
|
|||
"js-yaml": "~4.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@azure-tools/typespec-azure-resource-manager": ">=0.34.0 <1.0.0",
|
||||
"@azure-tools/typespec-autorest": ">=0.34.0 <1.0.0",
|
||||
"@azure-tools/typespec-azure-resource-manager": ">=0.35.0 <1.0.0",
|
||||
"@azure-tools/typespec-autorest": ">=0.35.0 <1.0.0",
|
||||
"@azure-tools/cadl-ranch-expect": "~0.7.0",
|
||||
"@azure-tools/cadl-ranch-specs": "~0.22.2",
|
||||
"@types/js-yaml": "~4.0.5",
|
||||
"@types/mocha": "~10.0.1",
|
||||
"@types/node": "^18.16.3",
|
||||
"@typespec/eslint-config-typespec": "~0.48.0",
|
||||
"@typespec/openapi": ">=0.48.0 <1.0.0",
|
||||
"@typespec/eslint-config-typespec": "~0.49.0",
|
||||
"@typespec/openapi": ">=0.49.0 <1.0.0",
|
||||
"c8": "~7.13.0",
|
||||
"eslint": "^8.44.0",
|
||||
"eslint-plugin-deprecation": "^1.4.1",
|
||||
"mocha": "~10.2.0",
|
||||
"rimraf": "~5.0.0",
|
||||
"typescript": "~5.1.3"
|
||||
|
|
|
@ -20,6 +20,7 @@ import {
|
|||
HttpOperationResponse,
|
||||
HttpServer,
|
||||
HttpOperation,
|
||||
HttpStatusCodeRange,
|
||||
} from "@typespec/http";
|
||||
import { getAddedOnVersions } from "@typespec/versioning";
|
||||
import {
|
||||
|
@ -407,10 +408,6 @@ function isAzureCoreModel(t: Type): boolean {
|
|||
);
|
||||
}
|
||||
|
||||
function hasDefaultStatusCode(response: HttpOperationResponse): boolean {
|
||||
return response.statusCode === "*";
|
||||
}
|
||||
|
||||
function getBodyFromResponse(context: SdkContext, response: HttpOperationResponse): Type | undefined {
|
||||
let body: Type | undefined = undefined;
|
||||
for (const innerResponse of response.responses) {
|
||||
|
@ -424,6 +421,13 @@ function getBodyFromResponse(context: SdkContext, response: HttpOperationRespons
|
|||
return body;
|
||||
}
|
||||
|
||||
function isHttpStatusCode(statusCodes: any): statusCodes is HttpStatusCodeRange {
|
||||
if (typeof statusCodes !== "object") {
|
||||
return false;
|
||||
}
|
||||
return "start" in statusCodes;
|
||||
}
|
||||
|
||||
function emitResponse(context: SdkContext, response: HttpOperationResponse): Record<string, any> {
|
||||
let type = undefined;
|
||||
const body = getBodyFromResponse(context, response);
|
||||
|
@ -447,11 +451,13 @@ function emitResponse(context: SdkContext, response: HttpOperationResponse): Rec
|
|||
type = getType(context, body);
|
||||
}
|
||||
}
|
||||
const statusCodes = [];
|
||||
if (hasDefaultStatusCode(response)) {
|
||||
const statusCodes: (string | number)[] = [];
|
||||
if (response.statusCodes === "*") {
|
||||
statusCodes.push("default");
|
||||
} else if (isHttpStatusCode(response.statusCodes)) {
|
||||
statusCodes.push(response.statusCodes.start);
|
||||
} else {
|
||||
statusCodes.push(parseInt(response.statusCode));
|
||||
statusCodes.push(response.statusCodes);
|
||||
}
|
||||
return {
|
||||
headers: emitResponseHeaders(context, response),
|
||||
|
@ -629,7 +635,7 @@ function emitBasicOperation(
|
|||
addAcceptParameter(context, operation, parameters);
|
||||
if (isErrorModel(context.program, response.type)) {
|
||||
// * is valid status code in cadl but invalid for autorest.python
|
||||
if (response.statusCode === "*") {
|
||||
if (response.statusCodes === "*") {
|
||||
exceptions.push(emittedResponse);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -368,19 +368,19 @@ class BasicClientOperationsMixin(BasicClientMixinABC):
|
|||
|
||||
response = pipeline_response.http_response
|
||||
|
||||
if response.status_code not in [200, 201]:
|
||||
if response.status_code not in [201, 200]:
|
||||
if _stream:
|
||||
response.read() # Load the body in memory and close the socket
|
||||
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
||||
raise HttpResponseError(response=response)
|
||||
|
||||
if response.status_code == 200:
|
||||
if response.status_code == 201:
|
||||
if _stream:
|
||||
deserialized = response.iter_bytes()
|
||||
else:
|
||||
deserialized = _deserialize(_models.User, response.json())
|
||||
|
||||
if response.status_code == 201:
|
||||
if response.status_code == 200:
|
||||
if _stream:
|
||||
deserialized = response.iter_bytes()
|
||||
else:
|
||||
|
@ -514,19 +514,19 @@ class BasicClientOperationsMixin(BasicClientMixinABC):
|
|||
|
||||
response = pipeline_response.http_response
|
||||
|
||||
if response.status_code not in [200, 201]:
|
||||
if response.status_code not in [201, 200]:
|
||||
if _stream:
|
||||
response.read() # Load the body in memory and close the socket
|
||||
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
||||
raise HttpResponseError(response=response)
|
||||
|
||||
if response.status_code == 200:
|
||||
if response.status_code == 201:
|
||||
if _stream:
|
||||
deserialized = response.iter_bytes()
|
||||
else:
|
||||
deserialized = _deserialize(_models.User, response.json())
|
||||
|
||||
if response.status_code == 201:
|
||||
if response.status_code == 200:
|
||||
if _stream:
|
||||
deserialized = response.iter_bytes()
|
||||
else:
|
||||
|
|
|
@ -173,19 +173,19 @@ class BasicClientOperationsMixin(BasicClientMixinABC):
|
|||
|
||||
response = pipeline_response.http_response
|
||||
|
||||
if response.status_code not in [200, 201]:
|
||||
if response.status_code not in [201, 200]:
|
||||
if _stream:
|
||||
await response.read() # Load the body in memory and close the socket
|
||||
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
||||
raise HttpResponseError(response=response)
|
||||
|
||||
if response.status_code == 200:
|
||||
if response.status_code == 201:
|
||||
if _stream:
|
||||
deserialized = response.iter_bytes()
|
||||
else:
|
||||
deserialized = _deserialize(_models.User, response.json())
|
||||
|
||||
if response.status_code == 201:
|
||||
if response.status_code == 200:
|
||||
if _stream:
|
||||
deserialized = response.iter_bytes()
|
||||
else:
|
||||
|
@ -319,19 +319,19 @@ class BasicClientOperationsMixin(BasicClientMixinABC):
|
|||
|
||||
response = pipeline_response.http_response
|
||||
|
||||
if response.status_code not in [200, 201]:
|
||||
if response.status_code not in [201, 200]:
|
||||
if _stream:
|
||||
await response.read() # Load the body in memory and close the socket
|
||||
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
||||
raise HttpResponseError(response=response)
|
||||
|
||||
if response.status_code == 200:
|
||||
if response.status_code == 201:
|
||||
if _stream:
|
||||
deserialized = response.iter_bytes()
|
||||
else:
|
||||
deserialized = _deserialize(_models.User, response.json())
|
||||
|
||||
if response.status_code == 201:
|
||||
if response.status_code == 200:
|
||||
if _stream:
|
||||
deserialized = response.iter_bytes()
|
||||
else:
|
||||
|
|
|
@ -159,21 +159,21 @@ class StandardClientOperationsMixin(StandardClientMixinABC):
|
|||
|
||||
response = pipeline_response.http_response
|
||||
|
||||
if response.status_code not in [200, 201]:
|
||||
if response.status_code not in [201, 200]:
|
||||
if _stream:
|
||||
response.read() # Load the body in memory and close the socket
|
||||
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
||||
raise HttpResponseError(response=response)
|
||||
|
||||
response_headers = {}
|
||||
if response.status_code == 200:
|
||||
if response.status_code == 201:
|
||||
response_headers["Operation-Location"] = self._deserialize(
|
||||
"str", response.headers.get("Operation-Location")
|
||||
)
|
||||
|
||||
deserialized = _deserialize(JSON, response.json())
|
||||
|
||||
if response.status_code == 201:
|
||||
if response.status_code == 200:
|
||||
response_headers["Operation-Location"] = self._deserialize(
|
||||
"str", response.headers.get("Operation-Location")
|
||||
)
|
||||
|
|
|
@ -86,21 +86,21 @@ class StandardClientOperationsMixin(StandardClientMixinABC):
|
|||
|
||||
response = pipeline_response.http_response
|
||||
|
||||
if response.status_code not in [200, 201]:
|
||||
if response.status_code not in [201, 200]:
|
||||
if _stream:
|
||||
await response.read() # Load the body in memory and close the socket
|
||||
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
||||
raise HttpResponseError(response=response)
|
||||
|
||||
response_headers = {}
|
||||
if response.status_code == 200:
|
||||
if response.status_code == 201:
|
||||
response_headers["Operation-Location"] = self._deserialize(
|
||||
"str", response.headers.get("Operation-Location")
|
||||
)
|
||||
|
||||
deserialized = _deserialize(JSON, response.json())
|
||||
|
||||
if response.status_code == 201:
|
||||
if response.status_code == 200:
|
||||
response_headers["Operation-Location"] = self._deserialize(
|
||||
"str", response.headers.get("Operation-Location")
|
||||
)
|
||||
|
|
|
@ -49,8 +49,6 @@ def build_legacy_create_job_request(**kwargs: Any) -> HttpRequest:
|
|||
|
||||
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
||||
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview"))
|
||||
accept = _headers.pop("Accept", "application/json")
|
||||
|
||||
# Construct URL
|
||||
_url = "/azure/core/lro/rpc/legacy/create-resource-poll-via-operation-location/jobs"
|
||||
|
||||
|
@ -58,7 +56,6 @@ def build_legacy_create_job_request(**kwargs: Any) -> HttpRequest:
|
|||
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
|
||||
|
||||
# Construct headers
|
||||
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
|
||||
if content_type is not None:
|
||||
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
|
||||
|
||||
|
@ -104,7 +101,7 @@ class LegacyClientOperationsMixin(LegacyClientMixinABC):
|
|||
|
||||
response = pipeline_response.http_response
|
||||
|
||||
if response.status_code not in [200, 202]:
|
||||
if response.status_code not in [202, 200]:
|
||||
if _stream:
|
||||
response.read() # Load the body in memory and close the socket
|
||||
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
||||
|
@ -112,15 +109,15 @@ class LegacyClientOperationsMixin(LegacyClientMixinABC):
|
|||
|
||||
deserialized = None
|
||||
response_headers = {}
|
||||
if response.status_code == 200:
|
||||
deserialized = _deserialize(JSON, response.json())
|
||||
|
||||
if response.status_code == 202:
|
||||
response_headers["Operation-Location"] = self._deserialize(
|
||||
"str", response.headers.get("Operation-Location")
|
||||
)
|
||||
response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))
|
||||
|
||||
if response.status_code == 200:
|
||||
deserialized = _deserialize(JSON, response.json())
|
||||
|
||||
if cls:
|
||||
return cls(pipeline_response, deserialized, response_headers)
|
||||
|
||||
|
@ -234,10 +231,16 @@ class LegacyClientOperationsMixin(LegacyClientMixinABC):
|
|||
kwargs.pop("error_map", None)
|
||||
|
||||
def get_long_running_output(pipeline_response):
|
||||
response_headers = {}
|
||||
response = pipeline_response.http_response
|
||||
response_headers["Operation-Location"] = self._deserialize(
|
||||
"str", response.headers.get("Operation-Location")
|
||||
)
|
||||
response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))
|
||||
|
||||
deserialized = _deserialize(_models.JobResult, response.json())
|
||||
if cls:
|
||||
return cls(pipeline_response, deserialized, {}) # type: ignore
|
||||
return cls(pipeline_response, deserialized, response_headers) # type: ignore
|
||||
return deserialized
|
||||
|
||||
if polling is True:
|
||||
|
|
|
@ -79,7 +79,7 @@ class LegacyClientOperationsMixin(LegacyClientMixinABC):
|
|||
|
||||
response = pipeline_response.http_response
|
||||
|
||||
if response.status_code not in [200, 202]:
|
||||
if response.status_code not in [202, 200]:
|
||||
if _stream:
|
||||
await response.read() # Load the body in memory and close the socket
|
||||
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
||||
|
@ -87,15 +87,15 @@ class LegacyClientOperationsMixin(LegacyClientMixinABC):
|
|||
|
||||
deserialized = None
|
||||
response_headers = {}
|
||||
if response.status_code == 200:
|
||||
deserialized = _deserialize(JSON, response.json())
|
||||
|
||||
if response.status_code == 202:
|
||||
response_headers["Operation-Location"] = self._deserialize(
|
||||
"str", response.headers.get("Operation-Location")
|
||||
)
|
||||
response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))
|
||||
|
||||
if response.status_code == 200:
|
||||
deserialized = _deserialize(JSON, response.json())
|
||||
|
||||
if cls:
|
||||
return cls(pipeline_response, deserialized, response_headers)
|
||||
|
||||
|
@ -211,10 +211,16 @@ class LegacyClientOperationsMixin(LegacyClientMixinABC):
|
|||
kwargs.pop("error_map", None)
|
||||
|
||||
def get_long_running_output(pipeline_response):
|
||||
response_headers = {}
|
||||
response = pipeline_response.http_response
|
||||
response_headers["Operation-Location"] = self._deserialize(
|
||||
"str", response.headers.get("Operation-Location")
|
||||
)
|
||||
response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))
|
||||
|
||||
deserialized = _deserialize(_models.JobResult, response.json())
|
||||
if cls:
|
||||
return cls(pipeline_response, deserialized, {}) # type: ignore
|
||||
return cls(pipeline_response, deserialized, response_headers) # type: ignore
|
||||
return deserialized
|
||||
|
||||
if polling is True:
|
||||
|
|
582
pnpm-lock.yaml
582
pnpm-lock.yaml
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче