Skip to content

Commit

Permalink
[v6] Support UUID string format (#701)
Browse files Browse the repository at this point in the history
* Support UUID string format

* Make Enum part of the MaperTypes
  • Loading branch information
joheredi authored Jul 23, 2020
1 parent 29e6eb3 commit e8a7a46
Show file tree
Hide file tree
Showing 14 changed files with 451 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/utils/valueHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export enum MapperTypes {
Date = "Date",
DateTime = "DateTime",
DateTimeRfc1123 = "DateTimeRfc1123",
Enum = "Enum",
Object = "Object",
Stream = "Stream",
String = "String",
Expand Down Expand Up @@ -45,6 +46,8 @@ export function getStringForValue(
case SchemaType.Boolean:
case MapperTypes.Boolean:
return value;
case SchemaType.Uuid:
case MapperTypes.Uuid:
case SchemaType.Date:
case MapperTypes.Date:
case SchemaType.DateTime:
Expand All @@ -54,7 +57,7 @@ export function getStringForValue(
case MapperTypes.String:
case MapperTypes.TimeSpan:
case SchemaType.Choice:
case "Enum":
case MapperTypes.Enum:
const valueString = !!value ? value.toString() : "";
return quotedStrings ? `"${valueString}"` : `${valueString}`;
default:
Expand Down
21 changes: 21 additions & 0 deletions test/integration/generated/uuid/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2020 Microsoft

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
27 changes: 27 additions & 0 deletions test/integration/generated/uuid/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Azure UuidClient SDK for JavaScript

This package contains an isomorphic SDK for UuidClient.

### Currently supported environments

- Node.js version 8.x.x or higher
- Browser JavaScript

### How to Install

```bash
npm install uuid
```

### How to use

#### Sample code

Refer the sample code in the [azure-sdk-for-js-samples](https://github.com/Azure/azure-sdk-for-js-samples) repository.

## Related projects

- [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js)


![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcdn%2Farm-cdn%2FREADME.png)
46 changes: 46 additions & 0 deletions test/integration/generated/uuid/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "uuid",
"author": "Microsoft Corporation",
"description": "A generated SDK for UuidClient.",
"version": "1.0.0-preview1",
"dependencies": { "@azure/core-http": "^1.1.4", "tslib": "^1.9.3" },
"keywords": ["node", "azure", "typescript", "browser", "isomorphic"],
"license": "MIT",
"main": "./dist/uuid.js",
"module": "./esm/uuidClient.js",
"types": "./esm/uuidClient.d.ts",
"devDependencies": {
"typescript": "^3.1.1",
"rollup": "^0.66.2",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"uglify-js": "^3.4.9"
},
"homepage": "https://github.com/Azure/azure-sdk-for-js",
"repository": {
"type": "git",
"url": "https://github.com/Azure/azure-sdk-for-js.git"
},
"bugs": { "url": "https://github.com/Azure/azure-sdk-for-js/issues" },
"files": [
"dist/**/*.js",
"dist/**/*.js.map",
"dist/**/*.d.ts",
"dist/**/*.d.ts.map",
"esm/**/*.js",
"esm/**/*.js.map",
"esm/**/*.d.ts",
"esm/**/*.d.ts.map",
"src/**/*.ts",
"README.md",
"rollup.config.js",
"tsconfig.json"
],
"scripts": {
"build": "tsc && rollup -c rollup.config.js && npm run minify",
"minify": "uglifyjs -c -m --comments --source-map \"content='./dist/uuid.js.map'\" -o ./dist/uuid.min.js ./dist/uuid.js",
"prepack": "npm install && npm run build"
},
"sideEffects": false,
"autoPublish": true
}
39 changes: 39 additions & 0 deletions test/integration/generated/uuid/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/

import rollup from "rollup";
import nodeResolve from "rollup-plugin-node-resolve";
import sourcemaps from "rollup-plugin-sourcemaps";

/**
* @type {rollup.RollupFileOptions}
*/
const config = {
input: "./esm/uuidClient.js",
external: ["@azure/core-http", "@azure/core-arm"],
output: {
file: "./dist/uuid.js",
format: "umd",
name: "Uuid",
sourcemap: true,
globals: {
"@azure/core-http": "coreHttp",
"@azure/core-arm": "coreArm"
},
banner: `/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/ `
},
plugins: [nodeResolve({ module: true }), sourcemaps()]
};

export default config;
45 changes: 45 additions & 0 deletions test/integration/generated/uuid/src/models/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/

import * as coreHttp from "@azure/core-http";

/**
* Contains response data for the uuid operation.
*/
export type GetUuidResponse = {
/**
* The parsed response body.
*/
body: string;

/**
* The underlying HTTP response.
*/
_response: coreHttp.HttpResponse & {
/**
* The response body as text (string format)
*/
bodyAsText: string;

/**
* The response body as parsed JSON or XML
*/
parsedBody: string;
};
};

/**
* Optional parameters.
*/
export interface UuidClientOptionalParams
extends coreHttp.ServiceClientOptions {
/**
* Overrides client endpoint.
*/
endpoint?: string;
}
33 changes: 33 additions & 0 deletions test/integration/generated/uuid/src/models/parameters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/

import { OperationURLParameter, OperationParameter } from "@azure/core-http";

export const $host: OperationURLParameter = {
parameterPath: "$host",
mapper: {
serializedName: "$host",
required: true,
type: {
name: "String"
}
},
skipEncoding: true
};

export const testUuid: OperationParameter = {
parameterPath: "testUuid",
mapper: {
defaultValue: "df79f5ce-4bf7-4680-8552-2317893986ed",
serializedName: "Test-Uuid",
required: true,
type: {
name: "Uuid"
}
}
};
60 changes: 60 additions & 0 deletions test/integration/generated/uuid/src/operations/get.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/

import * as coreHttp from "@azure/core-http";
import * as Parameters from "../models/parameters";
import { UuidClient } from "../uuidClient";
import { GetUuidResponse } from "../models";

/**
* Class representing a Get.
*/
export class Get {
private readonly client: UuidClient;

/**
* Initialize a new instance of the class Get class.
* @param client Reference to the service client
*/
constructor(client: UuidClient) {
this.client = client;
}

/**
* @param testUuid
* @param options The options parameters.
*/
uuid(
testUuid: string,
options?: coreHttp.OperationOptions
): Promise<GetUuidResponse> {
const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase(
options || {}
);
return this.client.sendOperationRequest(
{ testUuid, options: operationOptions },
uuidOperationSpec
) as Promise<GetUuidResponse>;
}
}
// Operation Specifications

const serializer = new coreHttp.Serializer({}, /* isXml */ false);

const uuidOperationSpec: coreHttp.OperationSpec = {
path: "/Uuid",
httpMethod: "GET",
responses: {
200: {
bodyMapper: { type: { name: "String" } }
}
},
urlParameters: [Parameters.$host],
headerParameters: [Parameters.testUuid],
serializer
};
9 changes: 9 additions & 0 deletions test/integration/generated/uuid/src/operations/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/

export * from "./get";
31 changes: 31 additions & 0 deletions test/integration/generated/uuid/src/uuidClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/

import * as operations from "./operations";
import * as Models from "./models";
import { UuidClientContext } from "./uuidClientContext";
import { UuidClientOptionalParams } from "./models";

class UuidClient extends UuidClientContext {
/**
* Initializes a new instance of the UuidClient class.
* @param $host server parameter
* @param options The parameter options
*/
constructor($host: string, options?: UuidClientOptionalParams) {
super($host, options);
this.get = new operations.Get(this);
}

get: operations.Get;
}

// Operation Specifications

export { UuidClient, UuidClientContext, Models as UuidModels };
export * from "./operations";
47 changes: 47 additions & 0 deletions test/integration/generated/uuid/src/uuidClientContext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/

import * as coreHttp from "@azure/core-http";
import { UuidClientOptionalParams } from "./models";

const packageName = "uuid";
const packageVersion = "1.0.0-preview1";

export class UuidClientContext extends coreHttp.ServiceClient {
$host: string;

/**
* Initializes a new instance of the UuidClientContext class.
* @param $host server parameter
* @param options The parameter options
*/
constructor($host: string, options?: UuidClientOptionalParams) {
if ($host === undefined) {
throw new Error("'$host' cannot be null");
}

// Initializing default values for options
if (!options) {
options = {};
}

if (!options.userAgent) {
const defaultUserAgent = coreHttp.getDefaultUserAgentValue();
options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`;
}

super(undefined, options);

this.requestContentType = "application/json; charset=utf-8";

this.baseUri = options.endpoint || "{$host}";

// Parameter assignments
this.$host = $host;
}
}
Loading

0 comments on commit e8a7a46

Please sign in to comment.