Skip to content

Commit

Permalink
[v6] Add tests for RequiredOptional and Non-String Enum + bonus (#758)
Browse files Browse the repository at this point in the history
* Required Optional tests

* update missing generated files

* remove unwanted change

* Update test/integration/requiredOptional.spec.ts

Co-authored-by: Deyaaeldeen Almahallawi <[email protected]>

* Address feedback

* Use include

Co-authored-by: Deyaaeldeen Almahallawi <[email protected]>
  • Loading branch information
joheredi and deyaaeldeen authored Oct 13, 2020
1 parent 2633e09 commit 468b960
Show file tree
Hide file tree
Showing 68 changed files with 3,394 additions and 103 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ More information about these can be found [here](https://github.com/Azure/autore
3. Hook up plugins into the AutoRest pipeline DAG, e.g.

```yaml
version: 3.0.6267
version: 3.0.6320
use-extension:
"@autorest/modelerfour": "4.15.419"
"@autorest/modelerfour": "4.15.421"

modelerfour:
# this runs a pre-namer step to clean up names
Expand Down
1 change: 1 addition & 0 deletions autorest.common
Submodule autorest.common added at 04b559
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"devDependencies": {
"@autorest/test-server": "^3.0.27",
"@azure/abort-controller": "^1.0.1",
"@microsoft.azure/autorest.testserver": "^2.10.51",
"@microsoft.azure/autorest.testserver": "^2.10.60",
"@types/chai": "^4.2.8",
"@types/express": "^4.17.2",
"@types/js-yaml": "3.12.1",
Expand Down
4 changes: 2 additions & 2 deletions test/integration/generated/bodyDate/src/operations/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class DateOperations {

/**
* Put max date value 9999-12-31
* @param dateBody
* @param dateBody date body
* @param options The options parameters.
*/
putMaxDate(
Expand Down Expand Up @@ -131,7 +131,7 @@ export class DateOperations {

/**
* Put min date value 0000-01-01
* @param dateBody
* @param dateBody date body
* @param options The options parameters.
*/
putMinDate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class Datetime {

/**
* Put max datetime value 9999-12-31T23:59:59.999Z
* @param datetimeBody
* @param datetimeBody datetime body
* @param options The options parameters.
*/
putUtcMaxDateTime(
Expand All @@ -127,7 +127,7 @@ export class Datetime {
/**
* This is against the recommendation that asks for 3 digits, but allow to test what happens in that
* scenario
* @param datetimeBody
* @param datetimeBody datetime body
* @param options The options parameters.
*/
putUtcMaxDateTime7Digits(
Expand Down Expand Up @@ -194,7 +194,7 @@ export class Datetime {

/**
* Put max datetime value with positive numoffset 9999-12-31t23:59:59.999+14:00
* @param datetimeBody
* @param datetimeBody datetime body
* @param options The options parameters.
*/
putLocalPositiveOffsetMaxDateTime(
Expand Down Expand Up @@ -244,7 +244,7 @@ export class Datetime {

/**
* Put max datetime value with positive numoffset 9999-12-31t23:59:59.999-14:00
* @param datetimeBody
* @param datetimeBody datetime body
* @param options The options parameters.
*/
putLocalNegativeOffsetMaxDateTime(
Expand Down Expand Up @@ -294,7 +294,7 @@ export class Datetime {

/**
* Put min datetime value 0001-01-01T00:00:00Z
* @param datetimeBody
* @param datetimeBody datetime body
* @param options The options parameters.
*/
putUtcMinDateTime(
Expand Down Expand Up @@ -328,7 +328,7 @@ export class Datetime {

/**
* Put min datetime value 0001-01-01T00:00:00+14:00
* @param datetimeBody
* @param datetimeBody datetime body
* @param options The options parameters.
*/
putLocalPositiveOffsetMinDateTime(
Expand Down Expand Up @@ -362,7 +362,7 @@ export class Datetime {

/**
* Put min datetime value 0001-01-01T00:00:00-14:00
* @param datetimeBody
* @param datetimeBody datetime body
* @param options The options parameters.
*/
putLocalNegativeOffsetMinDateTime(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class Datetimerfc1123 {

/**
* Put max datetime value Fri, 31 Dec 9999 23:59:59 GMT
* @param datetimeBody
* @param datetimeBody datetime body
* @param options The options parameters.
*/
putUtcMaxDateTime(
Expand Down Expand Up @@ -150,7 +150,7 @@ export class Datetimerfc1123 {

/**
* Put min datetime value Mon, 1 Jan 0001 00:00:00 GMT
* @param datetimeBody
* @param datetimeBody datetime body
* @param options The options parameters.
*/
putUtcMinDateTime(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class Duration {

/**
* Put a positive duration value
* @param durationBody
* @param durationBody duration body
* @param options The options parameters.
*/
putPositiveDuration(
Expand Down
32 changes: 32 additions & 0 deletions test/integration/generated/bodyFormData/src/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ export interface Paths1MqqetpFormdataStreamUploadfilePostRequestbodyContentMulti
fileName: string;
}

export interface Paths1P3Stk3FormdataStreamUploadfilesPostRequestbodyContentMultipartFormDataSchema {
/**
* Files to upload.
*/
fileContent: coreHttp.HttpRequestBody[];
}

/**
* Contains response data for the uploadFile operation.
*/
Expand Down Expand Up @@ -74,6 +81,31 @@ export type FormdataUploadFileViaBodyResponse = {
_response: coreHttp.HttpResponse;
};

/**
* Contains response data for the uploadFiles operation.
*/
export type FormdataUploadFilesResponse = {
/**
* BROWSER ONLY
*
* The response body as a browser Blob.
* Always `undefined` in node.js.
*/
blobBody?: Promise<Blob>;
/**
* NODEJS ONLY
*
* The response body as a node.js Readable stream.
* Always `undefined` in the browser.
*/
readableStreamBody?: NodeJS.ReadableStream;

/**
* The underlying HTTP response.
*/
_response: coreHttp.HttpResponse;
};

/**
* Optional parameters.
*/
Expand Down
18 changes: 18 additions & 0 deletions test/integration/generated/bodyFormData/src/models/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,21 @@ export const Paths1MqqetpFormdataStreamUploadfilePostRequestbodyContentMultipart
}
}
};

export const Paths1P3Stk3FormdataStreamUploadfilesPostRequestbodyContentMultipartFormDataSchema: coreHttp.CompositeMapper = {
type: {
name: "Composite",
className:
"Paths1P3Stk3FormdataStreamUploadfilesPostRequestbodyContentMultipartFormDataSchema",
modelProperties: {
fileContent: {
serializedName: "fileContent",
required: true,
type: {
name: "Sequence",
element: { type: { name: "Stream" } }
}
}
}
}
};
12 changes: 12 additions & 0 deletions test/integration/generated/bodyFormData/src/models/parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,15 @@ export const accept1: OperationParameter = {
}
}
};

export const fileContent2: OperationParameter = {
parameterPath: "fileContent",
mapper: {
serializedName: "fileContent",
required: true,
type: {
name: "Sequence",
element: { type: { name: "Stream" } }
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import * as Parameters from "../models/parameters";
import { BodyFormDataClient } from "../bodyFormDataClient";
import {
FormdataUploadFileResponse,
FormdataUploadFileViaBodyResponse
FormdataUploadFileViaBodyResponse,
FormdataUploadFilesResponse
} from "../models";

/**
Expand Down Expand Up @@ -66,6 +67,24 @@ export class Formdata {
uploadFileViaBodyOperationSpec
) as Promise<FormdataUploadFileViaBodyResponse>;
}

/**
* Upload multiple files
* @param fileContent Files to upload.
* @param options The options parameters.
*/
uploadFiles(
fileContent: coreHttp.HttpRequestBody[],
options?: coreHttp.OperationOptions
): Promise<FormdataUploadFilesResponse> {
const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase(
options || {}
);
return this.client.sendOperationRequest(
{ fileContent, options: operationOptions },
uploadFilesOperationSpec
) as Promise<FormdataUploadFilesResponse>;
}
}
// Operation Specifications

Expand Down Expand Up @@ -104,3 +123,19 @@ const uploadFileViaBodyOperationSpec: coreHttp.OperationSpec = {
mediaType: "binary",
serializer
};
const uploadFilesOperationSpec: coreHttp.OperationSpec = {
path: "/formdata/stream/uploadfiles",
httpMethod: "POST",
responses: {
200: {
bodyMapper: { type: { name: "Stream" }, serializedName: "parsedResponse" }
},
default: {
bodyMapper: Mappers.ErrorModel
}
},
formDataParameters: [Parameters.fileContent2],
urlParameters: [Parameters.$host],
headerParameters: [Parameters.contentType, Parameters.accept],
serializer
};
10 changes: 5 additions & 5 deletions test/integration/generated/bodyInteger/src/operations/int.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class Int {

/**
* Put max int32 value
* @param intBody
* @param intBody int body
* @param options The options parameters.
*/
putMax32(
Expand All @@ -150,7 +150,7 @@ export class Int {

/**
* Put max int64 value
* @param intBody
* @param intBody int body
* @param options The options parameters.
*/
putMax64(
Expand All @@ -168,7 +168,7 @@ export class Int {

/**
* Put min int32 value
* @param intBody
* @param intBody int body
* @param options The options parameters.
*/
putMin32(
Expand All @@ -186,7 +186,7 @@ export class Int {

/**
* Put min int64 value
* @param intBody
* @param intBody int body
* @param options The options parameters.
*/
putMin64(
Expand Down Expand Up @@ -220,7 +220,7 @@ export class Int {

/**
* Put datetime encoded as Unix time
* @param intBody date in seconds since 1970-01-01T00:00:00Z.
* @param intBody int body
* @param options The options parameters.
*/
putUnixTimeDate(
Expand Down
Loading

0 comments on commit 468b960

Please sign in to comment.