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

Rename namespace array to arrays #150

Merged
merged 17 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/rude-wombats-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@azure-tools/cadl-ranch-specs": patch
---

Change namesapce array to arrays
72 changes: 36 additions & 36 deletions packages/cadl-ranch-specs/cadl-ranch-summary.md
Original file line number Diff line number Diff line change
@@ -1,178 +1,178 @@
# Cadl Ranch Project summary

### Array_ItemTypes_Int32Value_get
### Arrays_ItemTypes_Int32Value_get

- Endpoint: `get /array/item-types/int32`
- Endpoint: `get /arrays/item-types/int32`

Expected Array response body:

```json
[1, 2]
```

### Array_ItemTypes_Int32Value_put
### Arrays_ItemTypes_Int32Value_put

- Endpoint: `put /array/item-types/int32`
- Endpoint: `put /arrays/item-types/int32`

Expected Array input body:

```json
[1, 2]
```

### Array_ItemTypes_Int64Value_get
### Arrays_ItemTypes_Int64Value_get

- Endpoint: `get /array/item-types/int64`
- Endpoint: `get /arrays/item-types/int64`

Expected Array response body:

```json
[0x7fffffffffffffff, -0x7fffffffffffffff]
```

### Array_ItemTypes_Int64Value_put
### Arrays_ItemTypes_Int64Value_put

- Endpoint: `put /array/item-types/int64`
- Endpoint: `put /arrays/item-types/int64`

Expected Array input body:

```json
[0x7fffffffffffffff, -0x7fffffffffffffff]
```

### Array_ItemTypes_BooleanValue_get
### Arrays_ItemTypes_BooleanValue_get

- Endpoint: `get /array/item-types/boolean`
- Endpoint: `get /arrays/item-types/boolean`

Expected Array response body:

```json
[true, false]
```

### Array_ItemTypes_BooleanValue_put
### Arrays_ItemTypes_BooleanValue_put

- Endpoint: `put /array/item-types/boolean`
- Endpoint: `put /arrays/item-types/boolean`

Expected Array input body:

```json
[true, false]
```

### Array_ItemTypes_StringValue_get
### Arrays_ItemTypes_StringValue_get

- Endpoint: `get /array/item-types/string`
- Endpoint: `get /arrays/item-types/string`

Expected Array response body:

```json
["hello", ""]
```

### Array_ItemTypes_StringValue_put
### Arrays_ItemTypes_StringValue_put

- Endpoint: `put /array/item-types/string`
- Endpoint: `put /arrays/item-types/string`

Expected Array input body:

```json
["hello", ""]
```

### Array_ItemTypes_Float32Value_get
### Arrays_ItemTypes_Float32Value_get

- Endpoint: `get /array/item-types/float32`
- Endpoint: `get /arrays/item-types/float32`

Expected Array response body:

```json
[42.42]
```

### Array_ItemTypes_Float32Value_put
### Arrays_ItemTypes_Float32Value_put

- Endpoint: `put /array/item-types/float32`
- Endpoint: `put /arrays/item-types/float32`

Expected Array input body:

```json
[42.42]
```

### Array_ItemTypes_DatetimeValue_get
### Arrays_ItemTypes_DatetimeValue_get

- Endpoint: `get /array/item-types/datetime`
- Endpoint: `get /arrays/item-types/datetime`

Expected Array response body:

```json
["2022-08-26T18:38:00Z"]
```

### Array_ItemTypes_DatetimeValue_put
### Arrays_ItemTypes_DatetimeValue_put

- Endpoint: `put /array/item-types/datetime`
- Endpoint: `put /arrays/item-types/datetime`

Expected Array input body:

```json
["2022-08-26T18:38:00Z"]
```

### Array_ItemTypes_DurationValue_get
### Arrays_ItemTypes_DurationValue_get

- Endpoint: `get /array/item-types/duration`
- Endpoint: `get /arrays/item-types/duration`

Expected Array response body:

```json
["P123DT22H14M12.011S"]
```

### Array_ItemTypes_DurationValue_put
### Arrays_ItemTypes_DurationValue_put

- Endpoint: `put /array/item-types/duration`
- Endpoint: `put /arrays/item-types/duration`

Expected Array input body:

```json
["P123DT22H14M12.011S"]
```

### Array_ItemTypes_UnknownValue_get
### Arrays_ItemTypes_UnknownValue_get

- Endpoint: `get /array/item-types/unknown`
- Endpoint: `get /arrays/item-types/unknown`

Expected Array response body:

```json
[1, 'hello', 'k3': null]
```

### Array_ItemTypes_UnknownValue_put
### Arrays_ItemTypes_UnknownValue_put

- Endpoint: `put /array/item-types/unknown`
- Endpoint: `put /arrays/item-types/unknown`

Expected Array input body:

```json
[1, 'hello', 'k3': null]
```

### Array_ItemTypes_ModelValue_get
### Arrays_ItemTypes_ModelValue_get

- Endpoint: `get /array/item-types/model`
- Endpoint: `get /arrays/item-types/model`

Expected Array response body:

```json
[{ "property": "hello" }, { "property": "world" }]
```

### Array_ItemTypes_ModelValue_put
### Arrays_ItemTypes_ModelValue_put

- Endpoint: `put /array/item-types/model`
- Endpoint: `put /arrays/item-types/model`

Expected Array input body:

Expand Down
67 changes: 0 additions & 67 deletions packages/cadl-ranch-specs/http/array/item-types/mockapi.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ using Cadl.Http;
using Azure.DPG;

@doc("Illustrates various of dictionaries.")
@scenarioService("/array/item-types")
namespace Array.ItemTypes;
@scenarioService("/arrays/item-types")
namespace Arrays.ItemTypes;

@doc("Template to have Array operations")
interface ArrayOperations<TArr, TDoc extends string> {
Expand Down
67 changes: 67 additions & 0 deletions packages/cadl-ranch-specs/http/arrays/item-types/mockapi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { passOnSuccess, ScenarioMockApi, mockapi, json, MockApi } from "@azure-tools/cadl-ranch-api";

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

interface MockApiGetPut {
get: MockApi;
put: MockApi;
}

/**
* Return the get and put operations
* @param route The route within /dictionary for your function.
* @param value The value you are expecting and will return.
*/
function createModelMockApis(route: string, value: any): MockApiGetPut {
const url = `/arrays/item-types/${route}`;
return {
get: mockapi.get(url, (req) => {
return {
status: 200,
body: json(value),
};
}),
put: mockapi.put(url, (req) => {
req.expect.bodyEquals(value);
return {
status: 204,
};
}),
};
}

const Int32ValueMock = createModelMockApis("int32", [1, 2]);
Scenarios.Arrays_ItemTypes_Int32Value_get = passOnSuccess(Int32ValueMock.get);
Scenarios.Arrays_ItemTypes_Int32Value_put = passOnSuccess(Int32ValueMock.put);

const Int64ValueMock = createModelMockApis("int64", [Number.MAX_SAFE_INTEGER, Number.MIN_SAFE_INTEGER]);
Scenarios.Arrays_ItemTypes_Int64Value_get = passOnSuccess(Int64ValueMock.get);
Scenarios.Arrays_ItemTypes_Int64Value_put = passOnSuccess(Int64ValueMock.put);

const BooleanValueMock = createModelMockApis("boolean", [true, false]);
Scenarios.Arrays_ItemTypes_BooleanValue_get = passOnSuccess(BooleanValueMock.get);
Scenarios.Arrays_ItemTypes_BooleanValue_put = passOnSuccess(BooleanValueMock.put);

const StringValueMock = createModelMockApis("string", ["hello", ""]);
Scenarios.Arrays_ItemTypes_StringValue_get = passOnSuccess(StringValueMock.get);
Scenarios.Arrays_ItemTypes_StringValue_put = passOnSuccess(StringValueMock.put);

const Float32ValueMock = createModelMockApis("float32", [42.42]);
Scenarios.Arrays_ItemTypes_Float32Value_get = passOnSuccess(Float32ValueMock.get);
Scenarios.Arrays_ItemTypes_Float32Value_put = passOnSuccess(Float32ValueMock.put);

const DatetimeValueMock = createModelMockApis("datetime", ["2022-08-26T18:38:00Z"]);
Scenarios.Arrays_ItemTypes_DatetimeValue_get = passOnSuccess(DatetimeValueMock.get);
Scenarios.Arrays_ItemTypes_DatetimeValue_put = passOnSuccess(DatetimeValueMock.put);

const DurationValueMock = createModelMockApis("duration", ["P123DT22H14M12.011S"]);
Scenarios.Arrays_ItemTypes_DurationValue_get = passOnSuccess(DurationValueMock.get);
Scenarios.Arrays_ItemTypes_DurationValue_put = passOnSuccess(DurationValueMock.put);

const UnknownValueMock = createModelMockApis("unknown", [1, "hello", null]);
Scenarios.Arrays_ItemTypes_UnknownValue_get = passOnSuccess(UnknownValueMock.get);
Scenarios.Arrays_ItemTypes_UnknownValue_put = passOnSuccess(UnknownValueMock.put);

const ModelValueMock = createModelMockApis("model", [{ property: "hello" }, { property: "world" }]);
Scenarios.Arrays_ItemTypes_ModelValue_get = passOnSuccess(ModelValueMock.get);
Scenarios.Arrays_ItemTypes_ModelValue_put = passOnSuccess(ModelValueMock.put);