Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e42e398

Browse files
authoredJan 21, 2021
PSD1 customization (#731)
* inital commit * wip * doc & test & bug fix * full test * rename
1 parent 87dba11 commit e42e398

File tree

8 files changed

+606
-103
lines changed

8 files changed

+606
-103
lines changed
 

‎docs/metadata.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Built-In Metadata Properties
2+
3+
Here is a list of available metadata properties you may specify in `readme.md`. They will affect the generated PowerShell manifest file (`*.psd1`) and the NuGet package manifest file (`*.nupkg`);
4+
5+
## Sample
6+
7+
```yaml
8+
metadata:
9+
authors: Microsoft Corporation
10+
owners: Microsoft Corporation
11+
description: 'Microsoft Azure PowerShell: $(service-name) cmdlets'
12+
copyright: Microsoft Corporation. All rights reserved.
13+
tags: Azure ResourceManager ARM PSModule $(service-name)
14+
companyName: Microsoft Corporation
15+
requireLicenseAcceptance: true
16+
licenseUri: https://aka.ms/azps-license
17+
projectUri: https://github.com/Azure/azure-powershell
18+
requiredModules:
19+
- name: Az.KeyVault
20+
version: 3.0.1
21+
requiredAssemblies:
22+
- ./custom/lib/third-party.dll
23+
nestedModules:
24+
- ./custom/my-custom.psm1
25+
formatsToProcess:
26+
- ./custom/my.formats.ps1xml
27+
typesToProcess:
28+
- ./custom/my.types.ps1xml
29+
scriptsToProcess:
30+
- ./custom/my.scripts.ps1xml
31+
functionsToExport:
32+
- Get-AzFunctionApp
33+
- New-AzFunctionApp
34+
- Remove-AzFunctionApp
35+
- Update-AzFunctionApp
36+
cmdletsToExport: []
37+
aliasesToExport: []
38+
```
39+
40+
## Notes
41+
42+
- Your context will overwrite (rather than append) the default values.
43+
- Use empty array `[]` if you want to overwrite default value with empty.

‎powershell/internal/project.ts

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,30 @@ export interface Metadata {
3131
companyName: string;
3232
licenseUri: string;
3333
projectUri: string;
34+
requiredModules: PsRequiredModule[];
35+
requiredModulesAsString: string;
36+
requiredAssemblies: string[];
37+
requiredAssembliesAsString: string;
38+
nestedModules: string[];
39+
nestedModulesAsString: string;
40+
formatsToProcess: string[];
41+
formatsToProcessAsString: string;
42+
typesToProcess: string[];
43+
typesToProcessAsString: string;
44+
scriptsToProcess: string[];
45+
scriptsToProcessAsString: string;
46+
functionsToExport: string[];
47+
functionsToExportAsString: string;
48+
cmdletsToExport: string[];
49+
cmdletsToExportAsString: string;
50+
aliasesToExport: string[];
51+
aliasesToExportAsString: string;
3452
}
3553

36-
54+
export interface PsRequiredModule {
55+
name: string;
56+
version: string;
57+
}
3758

3859
export class NewPSSwitch extends Boolean {
3960
get declaration(): string {
@@ -155,6 +176,7 @@ export class Project extends codeDomProject {
155176
this.accountsVersionMinimum = '2.2.3';
156177
this.helpLinkPrefix = await this.state.getValue('help-link-prefix');
157178
this.metadata = await this.state.getValue<Metadata>('metadata');
179+
this.preprocessMetadata();
158180
this.license = await this.state.getValue('header-text', '');
159181

160182
// Flags
@@ -223,4 +245,29 @@ export class Project extends codeDomProject {
223245
this.state.checkpoint();
224246
return this;
225247
}
248+
249+
/**
250+
* Preprocess some list properties in metadata to string properties,
251+
* so they can be easily used in csharp templates.
252+
*/
253+
private preprocessMetadata() {
254+
if (this.metadata) {
255+
this.metadata = {
256+
...this.metadata,
257+
requiredModulesAsString: this.metadata.requiredModules ? this.metadata.requiredModules.map(m => `@{ModuleName = '${m.name}'; ModuleVersion = '${m.version}'}`)?.join(', ') : 'undefined',
258+
requiredAssembliesAsString: this.convertToPsListAsString(this.metadata.requiredAssemblies),
259+
nestedModulesAsString: this.convertToPsListAsString(this.metadata.nestedModules),
260+
formatsToProcessAsString: this.convertToPsListAsString(this.metadata.formatsToProcess),
261+
typesToProcessAsString: this.convertToPsListAsString(this.metadata.typesToProcess),
262+
scriptsToProcessAsString: this.convertToPsListAsString(this.metadata.scriptsToProcess),
263+
functionsToExportAsString: this.convertToPsListAsString(this.metadata.functionsToExport),
264+
cmdletsToExportAsString: this.convertToPsListAsString(this.metadata.cmdletsToExport),
265+
aliasesToExportAsString: this.convertToPsListAsString(this.metadata.aliasesToExport)
266+
}
267+
}
268+
}
269+
270+
private convertToPsListAsString(items: string[]): string {
271+
return items ? items.map(i => `'${i}'`).join(', ') : 'undefined';
272+
}
226273
}

‎powershell/resources/psruntime/BuildTime/Cmdlets/ExportPsd1.cs

Lines changed: 168 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -12,114 +12,180 @@
1212

1313
namespace Microsoft.Rest.ClientRuntime.PowerShell
1414
{
15-
[Cmdlet(VerbsData.Export, "Psd1")]
16-
[DoNotExport]
17-
public class ExportPsd1 : PSCmdlet
18-
{
19-
[Parameter(Mandatory = true)]
20-
[ValidateNotNullOrEmpty]
21-
public string ExportsFolder { get; set; }
22-
23-
[Parameter(Mandatory = true)]
24-
[ValidateNotNullOrEmpty]
25-
public string CustomFolder { get; set; }
26-
27-
[Parameter(Mandatory = true)]
28-
[ValidateNotNullOrEmpty]
29-
public string Psd1Path { get; set; }
30-
31-
[Parameter(Mandatory = true)]
32-
public Guid ModuleGuid { get; set; }
33-
34-
private static readonly bool IsAzure = Convert.ToBoolean(@"${$project.azure}");
35-
private const string CustomFolderRelative = "${$project.customFolder}";
36-
private const string Indent = Psd1Indent;
37-
38-
protected override void ProcessRecord()
15+
[Cmdlet(VerbsData.Export, "Psd1")]
16+
[DoNotExport]
17+
public class ExportPsd1 : PSCmdlet
3918
{
40-
try
41-
{
42-
if (!Directory.Exists(ExportsFolder))
43-
{
44-
throw new ArgumentException($"Exports folder '{ExportsFolder}' does not exist");
45-
}
19+
[Parameter(Mandatory = true)]
20+
[ValidateNotNullOrEmpty]
21+
public string ExportsFolder { get; set; }
4622

47-
if (!Directory.Exists(CustomFolder))
48-
{
49-
throw new ArgumentException($"Custom folder '{CustomFolder}' does not exist");
50-
}
23+
[Parameter(Mandatory = true)]
24+
[ValidateNotNullOrEmpty]
25+
public string CustomFolder { get; set; }
5126

52-
string version = Convert.ToString(@"${$project.moduleVersion}");
53-
// Validate the module version should be semantic version
54-
// Following regex is official from https://semver.org/
55-
Regex rx = new Regex(@"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$", RegexOptions.Compiled);
56-
if (rx.Matches(version).Count != 1)
57-
{
58-
throw new ArgumentException("Module-version is not a valid Semantic Version");
59-
}
27+
[Parameter(Mandatory = true)]
28+
[ValidateNotNullOrEmpty]
29+
public string Psd1Path { get; set; }
6030

61-
string previewVersion = null;
62-
if (version.Contains('-'))
63-
{
64-
string[] versions = version.Split("-".ToCharArray(), 2);
65-
version = versions[0];
66-
previewVersion = versions[1];
67-
}
31+
[Parameter(Mandatory = true)]
32+
public Guid ModuleGuid { get; set; }
6833

69-
var sb = new StringBuilder();
70-
sb.AppendLine("@{");
71-
sb.AppendLine($@"{GuidStart} = '{ModuleGuid}'");
72-
sb.AppendLine($@"{Indent}RootModule = '{"${$project.psm1}"}'");
73-
sb.AppendLine($@"{Indent}ModuleVersion = '{version}'");
74-
sb.AppendLine($@"{Indent}CompatiblePSEditions = 'Core', 'Desktop'");
75-
sb.AppendLine($@"{Indent}Author = '{"${$project.metadata.authors}"}'");
76-
sb.AppendLine($@"{Indent}CompanyName = '{"${$project.metadata.companyName}"}'");
77-
sb.AppendLine($@"{Indent}Copyright = '{"${$project.metadata.copyright}"}'");
78-
sb.AppendLine($@"{Indent}Description = '{"${$project.metadata.description}"}'");
79-
sb.AppendLine($@"{Indent}PowerShellVersion = '5.1'");
80-
sb.AppendLine($@"{Indent}DotNetFrameworkVersion = '4.7.2'");
81-
sb.AppendLine($@"{Indent}RequiredAssemblies = '{"${$project.dll}"}'");
82-
83-
var customFormatPs1xmlFiles = Directory.GetFiles(CustomFolder)
84-
.Where(f => f.EndsWith(".format.ps1xml"))
85-
.Select(f => $"{CustomFolderRelative}/{Path.GetFileName(f)}");
86-
var formatList = customFormatPs1xmlFiles.Prepend("${$project.formatPs1xml}").ToPsList();
87-
sb.AppendLine($@"{Indent}FormatsToProcess = {formatList}");
88-
89-
var functionInfos = GetScriptCmdlets(ExportsFolder).ToArray();
90-
var cmdletsList = functionInfos.Select(fi => fi.Name).Distinct().Append("*").ToPsList();
91-
sb.AppendLine($@"{Indent}FunctionsToExport = {cmdletsList}");
92-
var aliasesList = functionInfos.SelectMany(fi => fi.ScriptBlock.Attributes).ToAliasNames().Append("*").ToPsList();
93-
sb.AppendLine($@"{Indent}AliasesToExport = {aliasesList}");
94-
95-
sb.AppendLine($@"{Indent}PrivateData = @{{");
96-
sb.AppendLine($@"{Indent}{Indent}PSData = @{{");
97-
98-
if (previewVersion != null)
99-
{
100-
sb.AppendLine($@"{Indent}{Indent}{Indent}Prerelease = {previewVersion}");
101-
}
102-
sb.AppendLine($@"{Indent}{Indent}{Indent}Tags = {"${$project.metadata.tags}".Split(' ').ToPsList().NullIfEmpty() ?? "''"}");
103-
sb.AppendLine($@"{Indent}{Indent}{Indent}LicenseUri = '{"${$project.metadata.licenseUri}"}'");
104-
sb.AppendLine($@"{Indent}{Indent}{Indent}ProjectUri = '{"${$project.metadata.projectUri}"}'");
105-
sb.AppendLine($@"{Indent}{Indent}{Indent}ReleaseNotes = ''");
106-
var profilesList = "${$project.profiles.map(each => `'` + each + `'`).join(', ')}";
107-
if (IsAzure && !String.IsNullOrEmpty(profilesList))
34+
private static readonly bool IsAzure = Convert.ToBoolean(@"${$project.azure}");
35+
private const string CustomFolderRelative = "${$project.customFolder}";
36+
private const string Indent = Psd1Indent;
37+
private const string Undefined = "undefined";
38+
private bool IsUndefined(string value) => string.Equals(Undefined, value, StringComparison.OrdinalIgnoreCase);
39+
40+
protected override void ProcessRecord()
10841
{
109-
sb.AppendLine($@"{Indent}{Indent}{Indent}Profiles = {profilesList}");
42+
try
43+
{
44+
if (!Directory.Exists(ExportsFolder))
45+
{
46+
throw new ArgumentException($"Exports folder '{ExportsFolder}' does not exist");
47+
}
48+
49+
if (!Directory.Exists(CustomFolder))
50+
{
51+
throw new ArgumentException($"Custom folder '{CustomFolder}' does not exist");
52+
}
53+
54+
string version = Convert.ToString(@"${$project.moduleVersion}");
55+
// Validate the module version should be semantic version
56+
// Following regex is official from https://semver.org/
57+
Regex rx = new Regex(@"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$", RegexOptions.Compiled);
58+
if (rx.Matches(version).Count != 1)
59+
{
60+
throw new ArgumentException("Module-version is not a valid Semantic Version");
61+
}
62+
63+
string previewVersion = null;
64+
if (version.Contains('-'))
65+
{
66+
string[] versions = version.Split("-".ToCharArray(), 2);
67+
version = versions[0];
68+
previewVersion = versions[1];
69+
}
70+
71+
var sb = new StringBuilder();
72+
sb.AppendLine("@{");
73+
sb.AppendLine($@"{GuidStart} = '{ModuleGuid}'");
74+
sb.AppendLine($@"{Indent}RootModule = '{"${$project.psm1}"}'");
75+
sb.AppendLine($@"{Indent}ModuleVersion = '{version}'");
76+
sb.AppendLine($@"{Indent}CompatiblePSEditions = 'Core', 'Desktop'");
77+
sb.AppendLine($@"{Indent}Author = '{"${$project.metadata.authors}"}'");
78+
sb.AppendLine($@"{Indent}CompanyName = '{"${$project.metadata.companyName}"}'");
79+
sb.AppendLine($@"{Indent}Copyright = '{"${$project.metadata.copyright}"}'");
80+
sb.AppendLine($@"{Indent}Description = '{"${$project.metadata.description}"}'");
81+
sb.AppendLine($@"{Indent}PowerShellVersion = '5.1'");
82+
sb.AppendLine($@"{Indent}DotNetFrameworkVersion = '4.7.2'");
83+
84+
// RequiredModules
85+
if (!IsUndefined("${$project.metadata.requiredModulesAsString}"))
86+
{
87+
sb.AppendLine($@"{Indent}RequiredModules = @({"${$project.metadata.requiredModulesAsString}"})");
88+
}
89+
90+
// RequiredAssemblies
91+
if (!IsUndefined("${$project.metadata.requiredAssembliesAsString}"))
92+
{
93+
sb.AppendLine($@"{Indent}RequiredAssemblies = @({"${$project.metadata.requiredAssembliesAsString}"})");
94+
}
95+
else
96+
{
97+
sb.AppendLine($@"{Indent}RequiredAssemblies = '{"${$project.dll}"}'");
98+
}
99+
100+
// NestedModules
101+
if (!IsUndefined("${$project.metadata.nestedModulesAsString}"))
102+
{
103+
sb.AppendLine($@"{Indent}NestedModules = @({"${$project.metadata.nestedModulesAsString}"})");
104+
}
105+
106+
// FormatsToProcess
107+
if (!IsUndefined("${$project.metadata.formatsToProcessAsString}"))
108+
{
109+
sb.AppendLine($@"{Indent}FormatsToProcess = @({"${$project.metadata.formatsToProcessAsString}"})");
110+
}
111+
else
112+
{
113+
var customFormatPs1xmlFiles = Directory.GetFiles(CustomFolder)
114+
.Where(f => f.EndsWith(".format.ps1xml"))
115+
.Select(f => $"{CustomFolderRelative}/{Path.GetFileName(f)}");
116+
var formatList = customFormatPs1xmlFiles.Prepend("${$project.formatPs1xml}").ToPsList();
117+
sb.AppendLine($@"{Indent}FormatsToProcess = {formatList}");
118+
}
119+
120+
// TypesToProcess
121+
if (!IsUndefined("${$project.metadata.typesToProcessAsString}"))
122+
{
123+
sb.AppendLine($@"{Indent}TypesToProcess = @({"${$project.metadata.typesToProcessAsString}"})");
124+
}
125+
126+
// ScriptsToProcess
127+
if (!IsUndefined("${$project.metadata.scriptsToProcessAsString}"))
128+
{
129+
sb.AppendLine($@"{Indent}ScriptsToProcess = @({"${$project.metadata.scriptsToProcessAsString}"})");
130+
}
131+
132+
var functionInfos = GetScriptCmdlets(ExportsFolder).ToArray();
133+
// FunctionsToExport
134+
if (!IsUndefined("${$project.metadata.functionsToExportAsString}"))
135+
{
136+
sb.AppendLine($@"{Indent}FunctionsToExport = @({"${$project.metadata.functionsToExportAsString}"})");
137+
}
138+
else
139+
{
140+
var cmdletsList = functionInfos.Select(fi => fi.Name).Distinct().Append("*").ToPsList();
141+
sb.AppendLine($@"{Indent}FunctionsToExport = {cmdletsList}");
142+
}
143+
144+
// AliasesToExport
145+
if (!IsUndefined("${$project.metadata.aliasesToExportAsString}"))
146+
{
147+
sb.AppendLine($@"{Indent}AliasesToExport = @({"${$project.metadata.aliasesToExportAsString}"})");
148+
}
149+
else
150+
{
151+
var aliasesList = functionInfos.SelectMany(fi => fi.ScriptBlock.Attributes).ToAliasNames().Append("*").ToPsList();
152+
sb.AppendLine($@"{Indent}AliasesToExport = {aliasesList}");
153+
}
154+
155+
// CmdletsToExport
156+
if (!IsUndefined("${$project.metadata.cmdletsToExportAsString}"))
157+
{
158+
sb.AppendLine($@"{Indent}CmdletsToExport = @({"${$project.metadata.cmdletsToExportAsString}"})");
159+
}
160+
161+
sb.AppendLine($@"{Indent}PrivateData = @{{");
162+
sb.AppendLine($@"{Indent}{Indent}PSData = @{{");
163+
164+
if (previewVersion != null)
165+
{
166+
sb.AppendLine($@"{Indent}{Indent}{Indent}Prerelease = {previewVersion}");
167+
}
168+
sb.AppendLine($@"{Indent}{Indent}{Indent}Tags = {"${$project.metadata.tags}".Split(' ').ToPsList().NullIfEmpty() ?? "''"}");
169+
sb.AppendLine($@"{Indent}{Indent}{Indent}LicenseUri = '{"${$project.metadata.licenseUri}"}'");
170+
sb.AppendLine($@"{Indent}{Indent}{Indent}ProjectUri = '{"${$project.metadata.projectUri}"}'");
171+
sb.AppendLine($@"{Indent}{Indent}{Indent}ReleaseNotes = ''");
172+
var profilesList = "${$project.profiles.map(each => `'` + each + `'`).join(', ')}";
173+
if (IsAzure && !String.IsNullOrEmpty(profilesList))
174+
{
175+
sb.AppendLine($@"{Indent}{Indent}{Indent}Profiles = {profilesList}");
176+
}
177+
178+
sb.AppendLine($@"{Indent}{Indent}}}");
179+
sb.AppendLine($@"{Indent}}}");
180+
sb.AppendLine(@"}");
181+
182+
File.WriteAllText(Psd1Path, sb.ToString());
183+
}
184+
catch (Exception ee)
185+
{
186+
Console.WriteLine($"${ee.GetType().Name}/{ee.StackTrace}");
187+
throw ee;
188+
}
110189
}
111-
112-
sb.AppendLine($@"{Indent}{Indent}}}");
113-
sb.AppendLine($@"{Indent}}}");
114-
sb.AppendLine(@"}");
115-
116-
File.WriteAllText(Psd1Path, sb.ToString());
117-
}
118-
catch (Exception ee)
119-
{
120-
Console.WriteLine($"${ee.GetType().Name}/{ee.StackTrace}");
121-
throw ee;
122-
}
123190
}
124-
}
125191
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
# Generate, build, return an object represents content of PSD1 file
3+
function GeneratePsd1()
4+
{
5+
param (
6+
$readme
7+
)
8+
Copy-Item -Path "$PSScriptRoot\readme\$readme" -Destination "$PSScriptRoot\readme.md" -Force
9+
autorest.cmd "$PSScriptRoot\readme.md" "--use:$PSScriptRoot\..\.." --output-folder:"$PSScriptRoot\output"
10+
. "$PSScriptRoot\output\build-module.ps1"
11+
return Import-PowerShellDataFile "$PSScriptRoot\output\Az.PetStore.psd1"
12+
}
13+
14+
Describe "Metadata support" {
15+
AfterEach {
16+
Remove-Item -Path "$PSScriptRoot\output\" -Force -Recurse -ErrorAction Ignore
17+
}
18+
19+
It "Should generate default value if metadata is empty" {
20+
$psd1 = GeneratePsd1('no-metadata.md.sample')
21+
$psd1.FunctionsToExport | Should -Be @('Get-AzPetStoreUser', '*')
22+
$psd1.FormatsToProcess | Should -Be './Az.PetStore.format.ps1xml'
23+
}
24+
25+
It "Should generate empty value if user inputs empty array" {
26+
$psd1 = GeneratePsd1('empty-value.md.sample')
27+
$psd1.FunctionsToExport | Should -Be @()
28+
}
29+
30+
It "Should generate PSD1 according to user's input" {
31+
$psd1 = GeneratePsd1('fully-customized.md.sample')
32+
$psd1.RequiredModules | Should -HaveCount 2
33+
$psd1.RequiredModules[0].ModuleName | Should -Be 'Az.KeyVault'
34+
$psd1.RequiredModules[1].ModuleVersion | Should -Be '1.0.0-preview'
35+
36+
$psd1.RequiredAssemblies | Should -Be @('./custom/lib/third-party.dll')
37+
$psd1.NestedModules | Should -Be @('./custom/my-custom.psm1')
38+
$psd1.FormatsToProcess | Should -Be @('./generated/Az.Functions.formats.ps1xml', './custom/my.formats.ps1xml')
39+
$psd1.TypesToProcess | Should -Be @('./custom/my.types.ps1xml')
40+
$psd1.ScriptsToProcess | Should -Be @('./custom/my.scripts.ps1xml')
41+
$psd1.FunctionsToExport | Should -Be @('Get-AzFunctionApp', 'New-AzFunctionApp', 'Remove-AzFunctionApp', 'Update-AzFunctionApp')
42+
$psd1.AliasesToExport | Should -Be @('GAF', 'NAF')
43+
$psd1.CmdletsToExport | Should -Be @('Get-MyItem', 'Remove-MyItem')
44+
}
45+
}
46+

‎tests/psd-customization/petstore.json

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
{
2+
"swagger": "2.0",
3+
"info": {
4+
"description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",
5+
"version": "1.0.5",
6+
"title": "Swagger Petstore",
7+
"termsOfService": "http://swagger.io/terms/",
8+
"contact": {
9+
"email": "apiteam@swagger.io"
10+
},
11+
"license": {
12+
"name": "Apache 2.0",
13+
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
14+
}
15+
},
16+
"host": "petstore.swagger.io",
17+
"basePath": "/v2",
18+
"paths": {
19+
"/user/{username}": {
20+
"get": {
21+
"tags": [
22+
"user"
23+
],
24+
"summary": "Get user by user name",
25+
"description": "",
26+
"operationId": "getUserByName",
27+
"produces": [
28+
"application/json"
29+
],
30+
"parameters": [
31+
{
32+
"name": "username",
33+
"in": "path",
34+
"description": "The name that needs to be fetched. Use user1 for testing. ",
35+
"required": true,
36+
"type": "string"
37+
}
38+
],
39+
"responses": {
40+
"200": {
41+
"description": "successful operation",
42+
"schema": {
43+
"$ref": "#/definitions/User"
44+
}
45+
},
46+
"400": {
47+
"description": "Invalid username supplied"
48+
},
49+
"404": {
50+
"description": "User not found"
51+
}
52+
}
53+
}
54+
}
55+
},
56+
"definitions": {
57+
"ApiResponse": {
58+
"type": "object",
59+
"properties": {
60+
"code": {
61+
"type": "integer",
62+
"format": "int32"
63+
},
64+
"type": {
65+
"type": "string"
66+
},
67+
"message": {
68+
"type": "string"
69+
}
70+
}
71+
},
72+
"User": {
73+
"type": "object",
74+
"properties": {
75+
"id": {
76+
"type": "integer",
77+
"format": "int64"
78+
},
79+
"username": {
80+
"type": "string"
81+
},
82+
"firstName": {
83+
"type": "string"
84+
},
85+
"lastName": {
86+
"type": "string"
87+
},
88+
"email": {
89+
"type": "string"
90+
},
91+
"password": {
92+
"type": "string"
93+
},
94+
"phone": {
95+
"type": "string"
96+
},
97+
"userStatus": {
98+
"type": "integer",
99+
"format": "int32",
100+
"description": "User Status"
101+
}
102+
}
103+
}
104+
}
105+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<!-- region Generated -->
2+
# Az.PetStore
3+
This directory contains the PowerShell module for the PetStore service.
4+
5+
---
6+
## Status
7+
[![Az.PetStore](https://img.shields.io/powershellgallery/v/Az.PetStore.svg?style=flat-square&label=Az.PetStore "Az.PetStore")](https://www.powershellgallery.com/packages/Az.PetStore/)
8+
9+
## Info
10+
- Modifiable: yes
11+
- Generated: all
12+
- Committed: yes
13+
- Packaged: yes
14+
15+
---
16+
## Detail
17+
This module was primarily generated via [AutoRest](https://github.com/Azure/autorest) using the [PowerShell](https://github.com/Azure/autorest.powershell) extension.
18+
19+
## Development
20+
For information on how to develop for `Az.PetStore`, see [how-to.md](how-to.md).
21+
<!-- endregion -->
22+
23+
# Azure PowerShell AutoRest Configuration
24+
25+
### AutoRest Configuration
26+
> see https://aka.ms/autorest
27+
28+
``` yaml
29+
input-file:
30+
- $(this-folder)/petstore.json
31+
32+
module-version: 0.1.4
33+
title: PetStore
34+
35+
azure: false
36+
powershell: true
37+
license-header: MICROSOFT_MIT_NO_VERSION
38+
metadata:
39+
authors: Microsoft Corporation
40+
owners: Microsoft Corporation
41+
description: 'Microsoft Azure PowerShell: $(service-name) cmdlets'
42+
copyright: Microsoft Corporation. All rights reserved.
43+
tags: Azure ResourceManager ARM PSModule $(service-name)
44+
companyName: Microsoft Corporation
45+
requireLicenseAcceptance: true
46+
licenseUri: https://aka.ms/azps-license
47+
projectUri: https://github.com/Azure/azure-powershell
48+
functionsToExport: []
49+
50+
prefix: Az
51+
subject-prefix: $(service-name)
52+
module-name: $(prefix).$(service-name)
53+
namespace: Microsoft.Azure.PowerShell.Cmdlets.$(service-name)
54+
55+
clear-output-folder: true
56+
output-folder: .
57+
```
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<!-- region Generated -->
2+
# Az.PetStore
3+
This directory contains the PowerShell module for the PetStore service.
4+
5+
---
6+
## Status
7+
[![Az.PetStore](https://img.shields.io/powershellgallery/v/Az.PetStore.svg?style=flat-square&label=Az.PetStore "Az.PetStore")](https://www.powershellgallery.com/packages/Az.PetStore/)
8+
9+
## Info
10+
- Modifiable: yes
11+
- Generated: all
12+
- Committed: yes
13+
- Packaged: yes
14+
15+
---
16+
## Detail
17+
This module was primarily generated via [AutoRest](https://github.com/Azure/autorest) using the [PowerShell](https://github.com/Azure/autorest.powershell) extension.
18+
19+
## Development
20+
For information on how to develop for `Az.PetStore`, see [how-to.md](how-to.md).
21+
<!-- endregion -->
22+
23+
# Azure PowerShell AutoRest Configuration
24+
25+
### AutoRest Configuration
26+
> see https://aka.ms/autorest
27+
28+
``` yaml
29+
input-file:
30+
- $(this-folder)/petstore.json
31+
32+
module-version: 0.1.4
33+
title: PetStore
34+
35+
azure: false
36+
powershell: true
37+
license-header: MICROSOFT_MIT_NO_VERSION
38+
metadata:
39+
authors: Microsoft Corporation
40+
owners: Microsoft Corporation
41+
description: 'Microsoft Azure PowerShell: $(service-name) cmdlets'
42+
copyright: Microsoft Corporation. All rights reserved.
43+
tags: Azure ResourceManager ARM PSModule $(service-name)
44+
companyName: Microsoft Corporation
45+
requireLicenseAcceptance: true
46+
licenseUri: https://aka.ms/azps-license
47+
projectUri: https://github.com/Azure/azure-powershell
48+
requiredModules:
49+
- name: Az.KeyVault
50+
version: 3.0.1
51+
- name: Az.Storage
52+
version: 1.0.0-preview
53+
requiredAssemblies:
54+
- ./custom/lib/third-party.dll
55+
nestedModules:
56+
- ./custom/my-custom.psm1
57+
formatsToProcess:
58+
- ./generated/Az.Functions.formats.ps1xml
59+
- ./custom/my.formats.ps1xml
60+
typesToProcess:
61+
- ./custom/my.types.ps1xml
62+
scriptsToProcess:
63+
- ./custom/my.scripts.ps1xml
64+
functionsToExport:
65+
- Get-AzFunctionApp
66+
- New-AzFunctionApp
67+
- Remove-AzFunctionApp
68+
- Update-AzFunctionApp
69+
cmdletsToExport:
70+
- Get-MyItem
71+
- Remove-MyItem
72+
aliasesToExport:
73+
- GAF
74+
- NAF
75+
76+
prefix: Az
77+
subject-prefix: $(service-name)
78+
module-name: $(prefix).$(service-name)
79+
namespace: Microsoft.Azure.PowerShell.Cmdlets.$(service-name)
80+
81+
clear-output-folder: true
82+
output-folder: .
83+
```
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<!-- region Generated -->
2+
# Az.PetStore
3+
This directory contains the PowerShell module for the PetStore service.
4+
5+
---
6+
## Status
7+
[![Az.PetStore](https://img.shields.io/powershellgallery/v/Az.PetStore.svg?style=flat-square&label=Az.PetStore "Az.PetStore")](https://www.powershellgallery.com/packages/Az.PetStore/)
8+
9+
## Info
10+
- Modifiable: yes
11+
- Generated: all
12+
- Committed: yes
13+
- Packaged: yes
14+
15+
---
16+
## Detail
17+
This module was primarily generated via [AutoRest](https://github.com/Azure/autorest) using the [PowerShell](https://github.com/Azure/autorest.powershell) extension.
18+
19+
## Development
20+
For information on how to develop for `Az.PetStore`, see [how-to.md](how-to.md).
21+
<!-- endregion -->
22+
23+
# Azure PowerShell AutoRest Configuration
24+
25+
### AutoRest Configuration
26+
> see https://aka.ms/autorest
27+
28+
``` yaml
29+
input-file:
30+
- $(this-folder)/petstore.json
31+
32+
module-version: 0.1.4
33+
title: PetStore
34+
35+
azure: false
36+
powershell: true
37+
license-header: MICROSOFT_MIT_NO_VERSION
38+
metadata:
39+
authors: Microsoft Corporation
40+
owners: Microsoft Corporation
41+
description: 'Microsoft Azure PowerShell: $(service-name) cmdlets'
42+
copyright: Microsoft Corporation. All rights reserved.
43+
tags: Azure ResourceManager ARM PSModule $(service-name)
44+
companyName: Microsoft Corporation
45+
requireLicenseAcceptance: true
46+
licenseUri: https://aka.ms/azps-license
47+
projectUri: https://github.com/Azure/azure-powershell
48+
49+
prefix: Az
50+
subject-prefix: $(service-name)
51+
module-name: $(prefix).$(service-name)
52+
namespace: Microsoft.Azure.PowerShell.Cmdlets.$(service-name)
53+
54+
clear-output-folder: true
55+
output-folder: .
56+
```

0 commit comments

Comments
 (0)
Please sign in to comment.