Skip to content

Commit

Permalink
Add typescript specific help when using cli --help (#828)
Browse files Browse the repository at this point in the history
* Add help command and fix small bug in pagination

* updae smoke

* fix readme

* Update smoke tests

* Update generates tests
  • Loading branch information
joheredi authored Jan 13, 2021
1 parent 810897e commit 48795ec
Show file tree
Hide file tree
Showing 40 changed files with 1,099 additions and 1,052 deletions.
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ More information about these can be found [here](https://github.com/Azure/autore
```yaml
version: 3.0.6320
use-extension:
"@autorest/modelerfour": "4.15.421"
"@autorest/modelerfour": "4.15.448"

modelerfour:
# this runs a pre-namer step to clean up names
Expand Down Expand Up @@ -57,6 +57,36 @@ typescript-scope/emitter:
output-artifact: typescript-files
```
## Help
```yaml
help-content:
typescript: # type: Help as defined in autorest-core/help.ts
activationScope: typescript
categoryFriendlyName: Typescript Generator
settings:
- key: azure-arm
description: Generate management plane flavor. Setting up the required flags for arm libraries
- key: license-header
description: "text to include as a header comment in generated files (magic strings: MICROSOFT_MIT, MICROSOFT_APACHE, MICROSOFT_MIT_NO_VERSION, MICROSOFT_APACHE_NO_VERSION, MICROSOFT_MIT_NO_CODEGEN)"
type: string
- key: add-credentials
description: include a credential property and constructor parameter supporting different authentication behaviors
- key: credential-scopes
type: string | string[]
description: Specify the scopes over which the credential functions. When generating management plane we default the scope to 'https://management.azure.com/.default'
- key: package-name
type: string
description: The name of your package. This is the name your package will be published under.
- key: source-code-folder-path
type: string
description: Where to output the generated code inside the output-folder. Defaults to src.
- key: generate-metadata
description: Whether to generate extra metadata in your package. For instance, generates a README file, license file etc if set to true.
- key: disable-async-iterators
description: Whether to generate pageable methods as AsyncIterators. Defaults to true.
```
## Language Specific Requirements: TypeScript
For TypeScript projects, simply import [autorest-extension-base](https://github.com/olydis/autorest-extension-base) which implements the AutoRest extension protocol and offers a simple API to register plugins.
Expand Down
4 changes: 1 addition & 3 deletions src/utils/extractPaginationDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,7 @@ function getResponseItemType(
// Find the 1st property containing the results to paginate over.
const itemProperty = responseSchema.properties?.find(property => {
const propertyName = getLanguageMetadata(property.language).name;
return (
propertyName === propertyName || itemName === property.serializedName
);
return propertyName === itemName || itemName === property.serializedName;
});

if (!itemProperty) {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/bodyDictionary.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ describe("BodyDictionary", () => {
} = await client.dictionary.getDictionaryItemNull();
const expected = {
"0": { "1": "one", "2": "two", "3": "three" },
"1": null,
"1": null as any,
"2": { "7": "seven", "8": "eight", "9": "nine" }
};
assert.deepEqual(result, expected);
Expand Down
20 changes: 10 additions & 10 deletions test/integration/generated/bodyDictionary/src/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -646,71 +646,71 @@ export type DictionaryGetArrayValidResponse = {

/** Contains response data for the getDictionaryNull operation. */
export type DictionaryGetDictionaryNullResponse = {
[propertyName: string]: any;
[propertyName: string]: { [propertyName: string]: 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: { [propertyName: string]: any };
parsedBody: { [propertyName: string]: { [propertyName: string]: string } };
};
};

/** Contains response data for the getDictionaryEmpty operation. */
export type DictionaryGetDictionaryEmptyResponse = {
[propertyName: string]: any;
[propertyName: string]: { [propertyName: string]: 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: { [propertyName: string]: any };
parsedBody: { [propertyName: string]: { [propertyName: string]: string } };
};
};

/** Contains response data for the getDictionaryItemNull operation. */
export type DictionaryGetDictionaryItemNullResponse = {
[propertyName: string]: any;
[propertyName: string]: { [propertyName: string]: 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: { [propertyName: string]: any };
parsedBody: { [propertyName: string]: { [propertyName: string]: string } };
};
};

/** Contains response data for the getDictionaryItemEmpty operation. */
export type DictionaryGetDictionaryItemEmptyResponse = {
[propertyName: string]: any;
[propertyName: string]: { [propertyName: string]: 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: { [propertyName: string]: any };
parsedBody: { [propertyName: string]: { [propertyName: string]: string } };
};
};

/** Contains response data for the getDictionaryValid operation. */
export type DictionaryGetDictionaryValidResponse = {
[propertyName: string]: any;
[propertyName: string]: { [propertyName: string]: 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: { [propertyName: string]: any };
parsedBody: { [propertyName: string]: { [propertyName: string]: string } };
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ export const arrayBody10: OperationParameter = {
required: true,
type: {
name: "Dictionary",
value: { type: { name: "any" } }
value: {
type: { name: "Dictionary", value: { type: { name: "String" } } }
}
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@ export class Dictionary {
* @param options The options parameters.
*/
putDictionaryValid(
arrayBody: { [propertyName: string]: any },
arrayBody: { [propertyName: string]: { [propertyName: string]: string } },
options?: coreHttp.OperationOptions
): Promise<coreHttp.RestResponse> {
const operationArguments: coreHttp.OperationArguments = {
Expand Down Expand Up @@ -2212,7 +2212,12 @@ const getDictionaryNullOperationSpec: coreHttp.OperationSpec = {
responses: {
200: {
bodyMapper: {
type: { name: "Dictionary", value: { type: { name: "any" } } }
type: {
name: "Dictionary",
value: {
type: { name: "Dictionary", value: { type: { name: "String" } } }
}
}
}
},
default: {
Expand All @@ -2229,7 +2234,12 @@ const getDictionaryEmptyOperationSpec: coreHttp.OperationSpec = {
responses: {
200: {
bodyMapper: {
type: { name: "Dictionary", value: { type: { name: "any" } } }
type: {
name: "Dictionary",
value: {
type: { name: "Dictionary", value: { type: { name: "String" } } }
}
}
}
},
default: {
Expand All @@ -2246,7 +2256,12 @@ const getDictionaryItemNullOperationSpec: coreHttp.OperationSpec = {
responses: {
200: {
bodyMapper: {
type: { name: "Dictionary", value: { type: { name: "any" } } }
type: {
name: "Dictionary",
value: {
type: { name: "Dictionary", value: { type: { name: "String" } } }
}
}
}
},
default: {
Expand All @@ -2263,7 +2278,12 @@ const getDictionaryItemEmptyOperationSpec: coreHttp.OperationSpec = {
responses: {
200: {
bodyMapper: {
type: { name: "Dictionary", value: { type: { name: "any" } } }
type: {
name: "Dictionary",
value: {
type: { name: "Dictionary", value: { type: { name: "String" } } }
}
}
}
},
default: {
Expand All @@ -2280,7 +2300,12 @@ const getDictionaryValidOperationSpec: coreHttp.OperationSpec = {
responses: {
200: {
bodyMapper: {
type: { name: "Dictionary", value: { type: { name: "any" } } }
type: {
name: "Dictionary",
value: {
type: { name: "Dictionary", value: { type: { name: "String" } } }
}
}
}
},
default: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2020 Microsoft
Copyright (c) 2021 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ export interface Encryption {
// @public
export interface EncryptionImages {
dataDiskImages?: DataDiskImageEncryption[];
osDiskImage?: DiskImageEncryption;
osDiskImage?: OSDiskImageEncryption;
}

// @public
Expand Down Expand Up @@ -1358,7 +1358,7 @@ export type GalleryImageUpdate = UpdateResourceDefinition & {

// @public
export type GalleryImageVersion = Resource & {
publishingProfile?: GalleryArtifactPublishingProfileBase;
publishingProfile?: GalleryImageVersionPublishingProfile;
readonly provisioningState?: GalleryImageVersionPropertiesProvisioningState;
storageProfile?: GalleryImageVersionStorageProfile;
readonly replicationStatus?: ReplicationStatus;
Expand Down Expand Up @@ -1417,7 +1417,7 @@ export type GalleryImageVersionsListByGalleryImageResponse = GalleryImageVersion
// @public
export interface GalleryImageVersionStorageProfile {
dataDiskImages?: GalleryDataDiskImage[];
osDiskImage?: GalleryDiskImage;
osDiskImage?: GalleryOSDiskImage;
source?: GalleryArtifactVersionSource;
}

Expand All @@ -1432,7 +1432,7 @@ export type GalleryImageVersionsUpdateResponse = GalleryImageVersion & {

// @public
export type GalleryImageVersionUpdate = UpdateResourceDefinition & {
publishingProfile?: GalleryArtifactPublishingProfileBase;
publishingProfile?: GalleryImageVersionPublishingProfile;
readonly provisioningState?: GalleryImageVersionPropertiesProvisioningState;
storageProfile?: GalleryImageVersionStorageProfile;
readonly replicationStatus?: ReplicationStatus;
Expand Down Expand Up @@ -1500,7 +1500,7 @@ export type ImageDataDisk = ImageDisk & {
export interface ImageDisk {
blobUri?: string;
caching?: CachingTypes;
diskEncryptionSet?: SubResource;
diskEncryptionSet?: DiskEncryptionSetParameters;
diskSizeGB?: number;
managedDisk?: SubResource;
snapshot?: SubResource;
Expand Down Expand Up @@ -2479,7 +2479,7 @@ export interface ManagedArtifact {
// @public
export type ManagedDiskParameters = SubResource & {
storageAccountType?: StorageAccountTypes;
diskEncryptionSet?: SubResource;
diskEncryptionSet?: DiskEncryptionSetParameters;
};

// @public
Expand Down Expand Up @@ -3823,7 +3823,7 @@ export interface VirtualMachineScaleSetListWithLinkResult {

// @public
export interface VirtualMachineScaleSetManagedDiskParameters {
diskEncryptionSet?: SubResource;
diskEncryptionSet?: DiskEncryptionSetParameters;
storageAccountType?: StorageAccountTypes;
}

Expand Down Expand Up @@ -3890,7 +3890,7 @@ export interface VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings {
}

// @public
export type VirtualMachineScaleSetReimageParameters = VirtualMachineReimageParameters & {
export type VirtualMachineScaleSetReimageParameters = VirtualMachineScaleSetVMReimageParameters & {
instanceIds?: string[];
};

Expand Down Expand Up @@ -4353,7 +4353,7 @@ export interface VirtualMachineScaleSetVMsPowerOffOptionalParams extends coreHtt

// @public
export interface VirtualMachineScaleSetVMsReimageOptionalParams extends coreHttp.OperationOptions {
vmScaleSetVMReimageInput?: VirtualMachineReimageParameters;
vmScaleSetVMReimageInput?: VirtualMachineScaleSetVMReimageParameters;
}

// @public
Expand Down
Loading

0 comments on commit 48795ec

Please sign in to comment.