Skip to content
This repository has been archived by the owner on Jan 21, 2025. It is now read-only.

Commit

Permalink
Merge branch 'main' into issues#689
Browse files Browse the repository at this point in the history
  • Loading branch information
v-hongli1 authored Sep 19, 2024
2 parents 7a9e7cd + 5e38bec commit e22d701
Show file tree
Hide file tree
Showing 10 changed files with 436 additions and 159 deletions.
6 changes: 6 additions & 0 deletions packages/cadl-ranch-expect/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @azure-tools/cadl-ranch-expect

## 0.15.4

### Patch Changes

- 5be049e: Bump typespec 0.60.0

## 0.15.3

### Patch Changes
Expand Down
10 changes: 5 additions & 5 deletions packages/cadl-ranch-expect/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@azure-tools/cadl-ranch-expect",
"version": "0.15.3",
"version": "0.15.4",
"description": "Cadl Library providing decorator and validation for Cadl Ranch specs",
"main": "dist/index.js",
"tspMain": "lib/lib.tsp",
Expand Down Expand Up @@ -30,9 +30,9 @@
"typescript": "~5.5.4"
},
"peerDependencies": {
"@typespec/compiler": "~0.59.0",
"@typespec/http": "~0.59.0",
"@typespec/rest": "~0.59.0",
"@typespec/versioning": "~0.59.0"
"@typespec/compiler": "~0.60.0",
"@typespec/http": "~0.60.0",
"@typespec/rest": "~0.60.0",
"@typespec/versioning": "~0.60.0"
}
}
12 changes: 12 additions & 0 deletions packages/cadl-ranch-specs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @azure-tools/cadl-ranch-specs

## 0.37.2

### Patch Changes

- 5be049e: Bump typespec 0.60.0
- 6272003: Added Type_Model_Templated_numericType test scenarios and corresponding Mock API implementations for type/model/templated.
Added Type_Model_Templated_float32Type test scenarios and corresponding Mock API implementations for type/model/templated.
Added Type_Model_Templated_int32Type test scenarios and corresponding Mock API implementations for type/model/templated.
- Updated dependencies [5be049e]
- @azure-tools/cadl-ranch-expect@0.15.4
- @azure-tools/cadl-ranch@0.14.6

## 0.37.1

### Patch Changes
Expand Down
71 changes: 71 additions & 0 deletions packages/cadl-ranch-specs/cadl-ranch-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -6511,6 +6511,77 @@ Expected input body:
}
```

### Type_Model_Templated_float32Type

- Endpoint: `put /type/model/templated/float32ValuesType`

Expected input body:

```json
{
"kind": "Float32Values",
"values": [0.5],
"value": 0.5
}
```

Expected response body:

```json
{
"kind": "Float32Values",
"values": [0.5],
"value": 0.5
}
```

### Type_Model_Templated_int32Type

- Endpoint: `put /type/model/templated/int32ValuesType`

Expected input body:

```json
{
"kind": "Int32Values",
"values": [1234],
"value": 1234
}
```

Expected response body:

```json
{
"kind": "Int32Values",
"values": [1234],
"value": 1234
}
```

### Type_Model_Templated_numericType

- Endpoint: `put /type/model/templated/numericType`

Expected input body:

```json
{
"kind": "Int32Values",
"values": [1234],
"value": 1234
}
```

Expected response body:

```json
{
"values": [1234],
"value": 1234
}
```

### Type_Model_Usage_input

- Endpoint: `get /type/model/usage/input`
Expand Down
131 changes: 131 additions & 0 deletions packages/cadl-ranch-specs/http/type/model/templated/main.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
import "@typespec/http";
import "@azure-tools/cadl-ranch-expect";
import "@azure-tools/typespec-client-generator-core";

using TypeSpec.Http;
using Azure.ClientGenerator.Core;

/**
* Illustrates the model templated cases. There is a base templated type and an instantiated type extending from it.
*/
@scenarioService("/type/model/templated")
namespace Type.Model.Templated;

@friendlyName("{name}Type", T)
model NumericType<T extends numeric> {
/**
* An array of numeric values.
*/
values: T[];

value: T;
}

/**
* An instantiated type representing int32 values type.
*/
model Int32ValuesType extends NumericType<int32> {
/**
* The Kind of the Int32ValuesType.
*/
kind: "Int32Values";
}

/**
* An instantiated type representing float32 values type.
*/
model Float32ValuesType extends NumericType<float32> {
/**
* The Kind of the Float32ValuesType.
*/
kind: "Float32Values";
}

@scenario
@scenarioDoc("""
Expected input body:
```json
{
"kind": "Int32Values",
"values":
[
1234
],
"value": 1234
}
```
Expected response body:
```json
{
"values":
[
1234
],
"value": 1234
}
```
""")
@route("/numericType")
@put
op numericType(@body input: NumericType<int32>): NumericType<int32>;

@scenario
@scenarioDoc("""
Expected input body:
```json
{
"kind": "Float32Values",
"values":
[
0.5
],
"value": 0.5
}
```
Expected response body:
```json
{
"kind": "Float32Values",
"values":
[
0.5
],
"value": 0.5
}
```
""")
@route("/float32ValuesType")
@put
op float32Type(@body input: Float32ValuesType): Float32ValuesType;

@scenario
@scenarioDoc("""
Expected input body:
```json
{
"kind": "Int32Values",
"values":
[
1234
],
"value": 1234
}
```
Expected response body:
```json
{
"kind": "Int32Values",
"values":
[
1234
],
"value": 1234
}
```
""")
@route("/int32ValuesType")
@put
op int32Type(@body input: Int32ValuesType): Int32ValuesType;
49 changes: 49 additions & 0 deletions packages/cadl-ranch-specs/http/type/model/templated/mockapi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { passOnSuccess, mockapi, json } from "@azure-tools/cadl-ranch-api";
import { ScenarioMockApi } from "@azure-tools/cadl-ranch-api";

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

Scenarios.Type_Model_Templated_numericType = passOnSuccess(
mockapi.put("/type/model/templated/numericType", (req) => {
const body = {
kind: "Int32Values",
values: [1234],
value: 1234,
};
req.expect.bodyEquals(body);
return {
status: 200,
body: json(body),
};
}),
);

Scenarios.Type_Model_Templated_float32Type = passOnSuccess(
mockapi.put("/type/model/templated/float32ValuesType", (req) => {
const body = {
kind: "Float32Values",
values: [0.5],
value: 0.5,
};
req.expect.bodyEquals(body);
return {
status: 200,
body: json(body),
};
}),
);

Scenarios.Type_Model_Templated_int32Type = passOnSuccess(
mockapi.put("/type/model/templated/int32ValuesType", (req) => {
const body = {
kind: "Int32Values",
values: [1234],
value: 1234,
};
req.expect.bodyEquals(body);
return {
status: 200,
body: json(body),
};
}),
);
24 changes: 12 additions & 12 deletions packages/cadl-ranch-specs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@azure-tools/cadl-ranch-specs",
"version": "0.37.1",
"version": "0.37.2",
"description": "Cadl scenarios and mock apis",
"main": "dist/index.js",
"type": "module",
Expand Down Expand Up @@ -35,22 +35,22 @@
"@azure-tools/cadl-ranch-api": "workspace:~"
},
"devDependencies": {
"@azure-tools/typespec-autorest": "0.45.0",
"@azure-tools/typespec-azure-resource-manager": "0.45.0",
"@azure-tools/typespec-client-generator-core": "0.45.0",
"@azure-tools/typespec-autorest": "0.46.0",
"@azure-tools/typespec-azure-resource-manager": "0.46.0",
"@azure-tools/typespec-client-generator-core": "0.46.0",
"@types/node": "^22.1.0",
"@typespec/openapi": "~0.59.0",
"@typespec/openapi3": "~0.59.0",
"@typespec/openapi": "~0.60.0",
"@typespec/openapi3": "~0.60.0",
"rimraf": "^6.0.1",
"typescript": "~5.5.4"
},
"peerDependencies": {
"@azure-tools/cadl-ranch-expect": "workspace:~",
"@azure-tools/typespec-azure-core": "~0.45.0",
"@typespec/compiler": "~0.59.0",
"@typespec/http": "~0.59.0",
"@typespec/rest": "~0.59.0",
"@typespec/versioning": "~0.59.0",
"@typespec/xml": "~0.59.0"
"@azure-tools/typespec-azure-core": "~0.46.0",
"@typespec/compiler": "~0.60.0",
"@typespec/http": "~0.60.0",
"@typespec/rest": "~0.60.0",
"@typespec/versioning": "~0.60.0",
"@typespec/xml": "~0.60.0"
}
}
8 changes: 8 additions & 0 deletions packages/cadl-ranch/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @azure-tools/cadl-ranch

## 0.14.6

### Patch Changes

- 5be049e: Bump typespec 0.60.0
- Updated dependencies [5be049e]
- @azure-tools/cadl-ranch-expect@0.15.4

## 0.14.5

### Patch Changes
Expand Down
8 changes: 4 additions & 4 deletions packages/cadl-ranch/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@azure-tools/cadl-ranch",
"version": "0.14.5",
"version": "0.14.6",
"description": "Cadl Ranch Tool to validate, run mock api, collect coverage.",
"main": "dist/index.js",
"type": "module",
Expand Down Expand Up @@ -32,9 +32,9 @@
"@azure-tools/cadl-ranch-expect": "workspace:~",
"@azure/identity": "^4.4.1",
"@types/js-yaml": "^4.0.5",
"@typespec/compiler": "~0.59.0",
"@typespec/http": "~0.59.0",
"@typespec/rest": "~0.59.0",
"@typespec/compiler": "~0.60.0",
"@typespec/http": "~0.60.0",
"@typespec/rest": "~0.60.0",
"ajv": "8.17.1",
"body-parser": "^1.20.2",
"deep-equal": "^2.2.0",
Expand Down
Loading

0 comments on commit e22d701

Please sign in to comment.