Skip to content
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
1 change: 1 addition & 0 deletions powershell/autorest-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ module-folder: $(current-folder)/generated
cmdlet-folder: $(module-folder)/cmdlets
model-cmdlet-folder: $(module-folder)/model-cmdlets
custom-cmdlet-folder: $(current-folder)/custom
utils-cmdlet-folder: $(current-folder)/utils
internal-cmdlet-folder: $(current-folder)/internal
test-folder: $(current-folder)/test
runtime-folder: $(module-folder)/runtime
Expand Down
1 change: 1 addition & 0 deletions powershell/generators/nuspec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export async function generateNuspec(project: Project | NewProject) {
<file src="${removeCd(project.customFolder)}/**/*.*" exclude="${removeCd(project.customFolder)}/readme.md;${removeCd(project.customFolder)}/**/*.cs" />
<file src="${removeCd(project.docsFolder)}/**/*.md" exclude="${removeCd(project.docsFolder)}/readme.md" />
<file src="${removeCd(project.exportsFolder)}/**/ProxyCmdletDefinitions.ps1" />
<file src="${removeCd(project.utilsFolder)}/**/*.*" />
</files>
</package>`, undefined, 'source-file-other');
}
Expand Down
4 changes: 4 additions & 0 deletions powershell/internal/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export class Project extends codeDomProject {
public cmdletFolder!: string;

public customFolder!: string;
public utilsFolder!: string;
public internalFolder!: string;
public testFolder!: string;
public runtimeFolder!: string;
Expand Down Expand Up @@ -193,6 +194,7 @@ export class Project extends codeDomProject {
this.cmdletFolder = await this.state.getValue('cmdlet-folder');

this.customFolder = await this.state.getValue('custom-cmdlet-folder');
this.utilsFolder = await this.state.getValue('utils-cmdlet-folder');
this.internalFolder = await this.state.getValue('internal-cmdlet-folder');
this.testFolder = await this.state.getValue('test-folder');
this.runtimeFolder = await this.state.getValue('runtime-folder');
Expand Down Expand Up @@ -250,6 +252,7 @@ export class NewProject extends codeDomProject {
public cmdletFolder!: string;

public customFolder!: string;
public utilsFolder!: string;
public internalFolder!: string;
public testFolder!: string;
public runtimeFolder!: string;
Expand Down Expand Up @@ -353,6 +356,7 @@ export class NewProject extends codeDomProject {
this.cmdletFolder = await this.state.getValue('cmdlet-folder');

this.customFolder = await this.state.getValue('custom-cmdlet-folder');
this.utilsFolder = await this.state.getValue('utils-cmdlet-folder');
this.internalFolder = await this.state.getValue('internal-cmdlet-folder');
this.testFolder = await this.state.getValue('test-folder');
this.runtimeFolder = await this.state.getValue('runtime-folder');
Expand Down
5 changes: 5 additions & 0 deletions powershell/llcsharp/model/namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ export class NewModelsNamespace extends Namespace {
this.NewResolveTypeDeclaration(schema, true, <NewState>state);
}
}
if (schemas.dictionaries) {
for (const schema of schemas.dictionaries) {
this.NewResolveTypeDeclaration(schema, true, <NewState>state);
}
}

if (schemas.any) {
for (const schema of schemas.any) {
Expand Down
5 changes: 4 additions & 1 deletion powershell/llcsharp/schema/schema-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { codeModelSchema, ArraySchema, CodeModel, Schema as NewSchema, StringSchema, BooleanSchema, NumberSchema, ByteArraySchema, DateTimeSchema, ObjectSchema, GroupSchema, isObjectSchema, SchemaType, GroupProperty, ParameterLocation, Operation, Parameter, VirtualParameter, getAllProperties, ImplementationLocation, OperationGroup, Request, SchemaContext, ConstantSchema, ChoiceSchema, DurationSchema, BinarySchema, DateSchema } from '@azure-tools/codemodel';
import { codeModelSchema, ArraySchema, UnixTimeSchema, CodeModel, Schema as NewSchema, StringSchema, BooleanSchema, NumberSchema, ByteArraySchema, DateTimeSchema, ObjectSchema, GroupSchema, isObjectSchema, SchemaType, GroupProperty, ParameterLocation, Operation, Parameter, VirtualParameter, getAllProperties, ImplementationLocation, OperationGroup, Request, SchemaContext, ConstantSchema, ChoiceSchema, DurationSchema, BinarySchema, DateSchema } from '@azure-tools/codemodel';

import { ModelState, codemodel, IntegerFormat, NumberFormat, StringFormat, JsonType } from '@azure-tools/codemodel-v3';
import { Schema } from '../code-model';
Expand Down Expand Up @@ -222,6 +222,9 @@ export class NewSchemaDefinitionResolver {
// fallback to int if the format isn't recognized
return new NewNumeric(<NumberSchema>schema, required, required ? 'int' : 'int?');

case SchemaType.UnixTime:
return new NewUnixTime(<UnixTimeSchema>schema, required);

case SchemaType.Number:
switch ((<NumberSchema>schema).precision) {
case 64:
Expand Down
3 changes: 3 additions & 0 deletions powershell/plugins/powershell-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ async function copyRequiredFiles(project: NewProject) {
// Runtime files
await copyResources(join(resources, 'psruntime'), async (fname, content) => project.state.writeFile(join(project.runtimeFolder, fname), content, undefined, sourceFileCSharp), project.overrides, transformOutput);

// utils cmdlets
await copyResources(join(resources, 'utils'), async (fname, content) => project.state.writeFile(join(project.utilsFolder, fname), content, undefined, sourceFileCSharp), project.overrides, transformOutput);

// Modules files
await copyBinaryResources(join(resources, 'modules'), async (fname, content) => project.state.writeFile(join(project.dependencyModuleFolder, fname), content, undefined, 'binary-file'));

Expand Down
16 changes: 16 additions & 0 deletions powershell/resources/utils/Unprotect-SecureString.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#This script converts securestring to plaintext

param(
[Parameter(Mandatory, ValueFromPipeline)]
[System.Security.SecureString]
${SecureString}
)

$ssPtr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureString)
try {
$plaintext = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($ssPtr)
} finally {
[System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($ssPtr)
}

return $plaintext
7 changes: 5 additions & 2 deletions tests-upgrade/AutoRestUpgradeTest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ function IsNeedIgnore([string]$inputFileName , [Array]$ignoreArray)
{
$Ignore =$True
break
} elseif ($ignoreDetail.Contains("*.") -and $inputFileName.EndsWith($ignoreDetail.Split(".")[-1])) {
$Ignore =$True
break
}
}
return $Ignore
Expand Down Expand Up @@ -117,8 +120,8 @@ function CompareGeneratedCode([string]$inputSourcePath,[string]$inputTargetPath,
#in m3Path
cd $inputSourcePath
$initFileList = Get-ChildItem -Recurse -force
$initIgnoreFileList = (($inputSourcePath+'\generated\modules'), ($inputSourcePath+'\.gitignore'),($inputSourcePath+'\tools\Resources\.gitignore'))
$targetIgnoreFileList = (($inputTargetPath+'\generated\modules'), ($inputTargetPath+'\.gitignore'),($inputTargetPath+'\tools\Resources\.gitignore'))
$initIgnoreFileList = (($inputSourcePath+'\generated\modules'), ($inputSourcePath+'\utils'), ($inputSourcePath+'\*.nuspec'), ($inputSourcePath+'\.gitignore'),($inputSourcePath+'\tools\Resources\.gitignore'))
$targetIgnoreFileList = (($inputTargetPath+'\generated\modules'), ($inputTargetPath+'\utils'),($inputTargetPath+'\*.nuspec'),($inputTargetPath+'\.gitignore'),($inputTargetPath+'\tools\Resources\.gitignore'))
#foreach initFileList and get the hashcode of them
foreach( $initFile in $initFileList)
{
Expand Down
1 change: 1 addition & 0 deletions tests-upgrade/Configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"datamodels-datatypes-integer",
"datamodels-datatypes-string",
"datamodels-datatypes-object",
"datamodels-datatypes-unixtime",
"datamodels-combineschema",
"directive-model",
"directive-tableformat",
Expand Down
10 changes: 10 additions & 0 deletions tests-upgrade/datamodels-datatypes-unixtime/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
### AutoRest Configuration
> see https://aka.ms/autorest

``` yaml
require:
- $(this-folder)/../readme.azure.noprofile.md
input-file:
- $(this-folder)/swagger.json

```
76 changes: 76 additions & 0 deletions tests-upgrade/datamodels-datatypes-unixtime/swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"swagger": "2.0",
"info": {
"title": "DatabricksClient",
"version": "2018-04-01",
"description": "ARM Databricks"
},
"host": "management.azure.com",
"schemes": [
"https"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"security": [
{
"azure_auth": [
"user_impersonation"
]
}
],
"securityDefinitions": {
"azure_auth": {
"type": "oauth2",
"authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize",
"flow": "implicit",
"description": "Azure Active Directory OAuth2 Flow",
"scopes": {
"user_impersonation": "impersonate your user account"
}
}
},
"paths": {
"/subscriptions/resourceGroup": {
"get": {
"tags": [
"Workspaces"
],
"operationId": "Workspaces_Get",
"description": "Gets the workspace.",
"responses": {
"200": {
"description": "OK-Return workspace."
},
"default": {
"description": "Error response describing why the operation failed.",
"schema": {
"$ref": "#/definitions/BasicErrorModel"
}
}
}
}
}
},
"definitions": {
"BasicErrorModel": {
"type": "object",
"required": [
"message",
"code"
],
"properties": {
"message": {
"type": "string"
},
"code": {
"type": "integer",
"format": "unixtime"
}
}
}
}
}