Skip to content

Commit

Permalink
azure-http-specs, update azure example scenario name (#1930)
Browse files Browse the repository at this point in the history
Move `@scenario` from client.tsp to main.tsp

When in client.tsp, the namespace there would be the scenario name of
this test, which appears not correct.

![image](https://github.com/user-attachments/assets/dbdb394b-425a-4a61-af59-0f48a15f0932)

After this, it should be under `Azure > Example > Basic`.

This should not affect code generated by emitters.
  • Loading branch information
weidongxu-microsoft authored Nov 29, 2024
1 parent 3c2aafe commit d69f7ad
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 73 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
packages:
- "@azure-tools/azure-http-specs"
---

Update scenario name on azure example scenario
72 changes: 36 additions & 36 deletions packages/azure-http-specs/spec-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,42 @@ Expected response body:
}
```

### Azure_Example_Basic

- Endpoint: `post /azure/example/basic/basic`

Expected request and response is same as the JSON example at examples/2022-12-01-preview/basic.json

When generate the code, one need to set the "examples-directory" option.

Expected query parameter: query-param=query&api-version=2022-12-01-preview
Expected header parameter: header-param=header

Expected input body:

```json
{
"stringProperty": "text",
"modelProperty": {
"int32Property": 1,
"float32Property": 1.5,
"enumProperty": "EnumValue1"
},
"arrayProperty": ["item"],
"recordProperty": {
"record": "value"
}
}
```

Expected response body:

```json
{
"stringProperty": "text"
}
```

### Azure_Payload_Pageable_list

- Endpoint: `get /azure/payload/pageable`
Expand Down Expand Up @@ -1389,42 +1425,6 @@ Expected header parameters:
Expected response header:
- x-ms-client-request-id=<uuid string same with request header>

### Client_AzureExampleClient_basicAction

- Endpoint: `post /azure/example/basic/basic`

Expected request and response is same as the JSON example at examples/2022-12-01-preview/basic.json

When generate the code, one need to set the "examples-directory" option.

Expected query parameter: query-param=query&api-version=2022-12-01-preview
Expected header parameter: header-param=header

Expected input body:

```json
{
"stringProperty": "text",
"modelProperty": {
"int32Property": 1,
"float32Property": 1.5,
"enumProperty": "EnumValue1"
},
"arrayProperty": ["item"],
"recordProperty": {
"record": "value"
}
}
```

Expected response body:

```json
{
"stringProperty": "text"
}
```

### Client_Naming_Header_request

- Endpoint: `post /client/naming/header`
Expand Down
38 changes: 2 additions & 36 deletions packages/azure-http-specs/specs/azure/example/basic/client.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,15 @@ using Spector;

@TypeSpec.Versioning.useDependency(_Specs_.Azure.Example.Basic.Versions.v2022_12_01_preview)
@route("/azure/example/basic")
namespace Client;
namespace AzureExampleBasicClient;

@@clientNamespace(Client, "azure.example.basic", "java");
@@clientNamespace(AzureExampleBasicClient, "azure.example.basic", "java");
@@clientNamespace(_Specs_.Azure.Example.Basic, "azure.example.basic", "java");

@client({
name: "AzureExampleClient",
service: _Specs_.Azure.Example.Basic,
})
interface AzureExampleClient {
@scenario
@scenarioDoc("""
Expected request and response is same as the JSON example at examples/2022-12-01-preview/basic.json
When generate the code, one need to set the "examples-directory" option.
Expected query parameter: query-param=query&api-version=2022-12-01-preview
Expected header parameter: header-param=header
Expected input body:
```json
{
"stringProperty": "text",
"modelProperty": {
"int32Property": 1,
"float32Property": 1.5,
"enumProperty": "EnumValue1"
},
"arrayProperty": [
"item"
],
"recordProperty": {
"record": "value"
}
}
```
Expected response body:
```json
{
"stringProperty": "text"
}
```
""")
basicAction is _Specs_.Azure.Example.Basic.ServiceOperationGroup.basic;
}
34 changes: 34 additions & 0 deletions packages/azure-http-specs/specs/azure/example/basic/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,40 @@ using Spector;
versioned: Versions,
}
)
@scenario
@scenarioDoc("""
Expected request and response is same as the JSON example at examples/2022-12-01-preview/basic.json
When generate the code, one need to set the "examples-directory" option.
Expected query parameter: query-param=query&api-version=2022-12-01-preview
Expected header parameter: header-param=header
Expected input body:
```json
{
"stringProperty": "text",
"modelProperty": {
"int32Property": 1,
"float32Property": 1.5,
"enumProperty": "EnumValue1"
},
"arrayProperty": [
"item"
],
"recordProperty": {
"record": "value"
}
}
```
Expected response body:
```json
{
"stringProperty": "text"
}
```
""")
namespace _Specs_.Azure.Example.Basic;

enum Versions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { json, passOnSuccess, ScenarioMockApi } from "@typespec/spec-api";

export const Scenarios: Record<string, ScenarioMockApi> = {};

Scenarios.Client_AzureExampleClient_basicAction = passOnSuccess({
Scenarios.Azure_Example_Basic = passOnSuccess({
uri: "/azure/example/basic/basic",
method: "post",
request: {
Expand Down

0 comments on commit d69f7ad

Please sign in to comment.