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

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
mcgallan committed Oct 11, 2024
1 parent f1bc36f commit 8244e3c
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 108 deletions.
2 changes: 1 addition & 1 deletion .changeset/rich-comics-draw.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"@azure-tools/cadl-ranch-specs": minor
---

Add test in parameters/query-optional.
Add optional parameter ordering test in parameter\body-optionality.
64 changes: 35 additions & 29 deletions packages/cadl-ranch-specs/cadl-ranch-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -2489,6 +2489,41 @@ Expected request body for `set`

Expected no request body for `omit`

### Parameters_BodyOptionality_OptionalityOrdering

- Endpoints:
- `head /parameters/body-optionality/optional-ordering/startwithequired`
- `head /parameters/body-optionality/optional-ordering/startwithoptional`

Test scenario for using a combination of required parameters first and optional parameters later.

Should generate an operation like below:

```
orderingWithRequiredStart(start: string, end?: string)
```

Expected parameter: api-version=2022-12-01-preview
Expected request body:

```json
{ "start": "required" }
```

Another scenario using a combination of optional parameters first and required parameters later

Should generate an operation like below:

```
orderingWithOptionalStart(end: string, start?: string)
```

Expected request body:

```json
{ "end": "required" }
```

### Parameters_BodyOptionality_requiredExplicit

- Endpoint: `post /parameters/body-optionality/required-explicit`
Expand Down Expand Up @@ -2549,35 +2584,6 @@ This test is testing sending a ssv collection format array query parameters

This test is testing sending a tsv collection format array query parameters

### Parameters_QueryOptionality_OrderingWithOptionalStart

- Endpoint: `head /parameters/query-optionality/startwithoptional`

Test scenarios for using a combination of optional query parameters first and required query parameters later

Should generate an operation like below:

```
orderingWithOptionalStart(end: string, start?: string)
```

Expected query parameter: end=required

### Parameters_QueryOptionality_OrderingWithRequiredStart

- Endpoint: `head /parameters/query-optionality/startwithequired`

Test scenarios for using a combination of required query parameters first and optional query parameters later.

Should generate an operation like below:

```
orderingWithRequiredStart(start: string, end?: string)
```

Expected query parameter: api-version=2022-12-01-preview
Expected query parameter: start=required

### Parameters_Spread_Alias_spreadAsRequestBody

- Endpoint: `put /parameters/spread/alias/request-body`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,44 @@ namespace OptionalExplicit {
op omit(@body body?: BodyModel): NoContentResponse;
}

@scenario
@scenarioDoc("""
Test scenario for using a combination of required parameters first and optional parameters later.
Should generate an operation like below:
```
orderingWithRequiredStart(start: string, end?: string)
```
Expected parameter: api-version=2022-12-01-preview
Expected request body:
```json
{ "start": "required" }
```
Another scenario using a combination of optional parameters first and required parameters later
Should generate an operation like below:
```
orderingWithOptionalStart(end: string, start?: string)
```
Expected request body:
```json
{ "end": "required" }
```
""")
@operationGroup
@route("/optional-ordering")
namespace OptionalityOrdering {
@route("/startwithequired")
@head
op OrderingWithRequiredStart(start: string, end?: string): void;

@route("/startwithoptional")
@head
op OrderingWithOptionalStart(start?: string, end: string): void;
}

@scenario
@scenarioDoc("""
Scenario defining how an implicit required body parameter is specified.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,21 @@ Scenarios.Parameters_BodyOptionality_requiredImplicit = passOnSuccess(
return { status: 204 };
}),
);

Scenarios.Parameters_BodyOptionality_OptionalityOrdering = passOnSuccess([
mockapi.head("/parameters/body-optionality/optional-ordering/startwithequired", (req) => {
req.expect.bodyEquals({ start: "required" });
return { status: 204 };
}),
mockapi.head("/parameters/body-optionality/optional-ordering/startwithoptional", (req) => {
req.expect.bodyEquals({ end: "required" });
return { status: 204 };
}),
]);

Scenarios.Parameters_BodyOptionality_OrderingWithOptionalStart = passOnSuccess(
mockapi.head("/parameters/query-optionality/startwithoptional", (req) => {
req.expect.bodyEquals({ end: "required" });
return { status: 204 };
}),
);

This file was deleted.

This file was deleted.

0 comments on commit 8244e3c

Please sign in to comment.