Skip to content

Commit 13e6646

Browse files
Fix tests, add workaround for required properties field
1 parent c49248f commit 13e6646

File tree

15 files changed

+141
-174
lines changed

15 files changed

+141
-174
lines changed

generator/processors/Microsoft.Kusto.ts

Lines changed: 130 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -2,152 +2,159 @@ import { SchemaPostProcessor } from '../models';
22
import { apiVersionCompare } from '../utils';
33

44
const clusterDataConnections = (apiVersion: string) => ({
5-
type: 'object',
6-
oneOf: [
7-
{
8-
$ref: '#/definitions/GenevaDataConnection'
9-
},
10-
{
11-
$ref: '#/definitions/GenevaLegacyDataConnection'
12-
}
13-
],
14-
properties: {
15-
name: {
16-
type: 'string',
17-
description: 'The data connection name'
18-
},
19-
type: {
20-
enum: [
21-
'Microsoft.Kusto/clusters/dataConnections'
22-
]
23-
},
24-
apiVersion: {
25-
type: 'string',
26-
enum: [
27-
apiVersion
28-
]
29-
}
5+
type: 'object',
6+
oneOf: [
7+
{
8+
$ref: '#/definitions/GenevaDataConnection'
9+
},
10+
{
11+
$ref: '#/definitions/GenevaLegacyDataConnection'
12+
}
13+
],
14+
properties: {
15+
name: {
16+
type: 'string',
17+
description: 'The data connection name'
18+
},
19+
type: {
20+
enum: [
21+
'Microsoft.Kusto/clusters/dataConnections'
22+
]
3023
},
31-
required: [
32-
'apiVersion',
33-
'properties',
34-
'type'
35-
],
36-
description: 'Microsoft.Kusto/clusters/dataConnections'
24+
apiVersion: {
25+
type: 'string',
26+
enum: [
27+
apiVersion
28+
]
29+
}
30+
},
31+
required: [
32+
'apiVersion',
33+
'properties',
34+
'type'
35+
],
36+
description: 'Microsoft.Kusto/clusters/dataConnections'
3737
});
3838

3939
const genevaDataConnectionProperties = () => ({
40-
type: 'object',
41-
properties: {
42-
genevaEnvironment: {
43-
type: 'string',
44-
'description': 'The Geneva environment of the geneva data connection.'
45-
}
46-
},
47-
required: [
48-
'genevaEnvironment'
49-
],
50-
description: 'Class representing the Kusto Geneva (GDS) connection properties.'
40+
type: 'object',
41+
properties: {
42+
genevaEnvironment: {
43+
type: 'string',
44+
'description': 'The Geneva environment of the geneva data connection.'
45+
}
46+
},
47+
required: [
48+
'genevaEnvironment'
49+
],
50+
description: 'Class representing the Kusto Geneva (GDS) connection properties.'
5151
});
5252

5353
const genevaDataConnection = () => ({
54-
type: 'object',
54+
type: 'object',
55+
properties: {
5556
properties: {
56-
properties: {
57-
oneOf: [
58-
{
59-
$ref: '#/definitions/GenevaDataConnectionProperties'
60-
},
61-
{
62-
$ref: 'https://schema.management.azure.com/schemas/common/definitions.json#/definitions/expression'
63-
}
64-
],
65-
description: 'Geneva (DGS) data connection properties'
66-
},
67-
kind: {
68-
type: 'string',
69-
enum: [
70-
'Geneva'
71-
]
72-
}
57+
oneOf: [
58+
{
59+
$ref: '#/definitions/GenevaDataConnectionProperties'
60+
},
61+
{
62+
$ref: 'https://schema.management.azure.com/schemas/common/definitions.json#/definitions/expression'
63+
}
64+
],
65+
description: 'Geneva (DGS) data connection properties'
7366
},
74-
required: [
75-
'kind'
76-
],
77-
description: 'Information about the Geneva (GDS) data connection'
67+
kind: {
68+
type: 'string',
69+
enum: [
70+
'Geneva'
71+
]
72+
}
73+
},
74+
required: [
75+
'kind'
76+
],
77+
description: 'Information about the Geneva (GDS) data connection'
7878
});
7979

8080
const genevaLegacyDataConnectionProperties = () => ({
81-
type: 'object',
82-
properties: {
83-
genevaEnvironment: {
84-
type: 'string',
85-
description: 'The Geneva environment of the geneva data connection.'
86-
},
87-
mdsAccounts: {
88-
type: 'array',
89-
description: 'The list of mds accounts of the geneva data connection.'
90-
},
91-
isScrubbed: {
92-
type: 'boolean',
93-
description: 'Indicates whether the data is scrubbed.'
94-
}
95-
},
96-
required: [
97-
'genevaEnvironment',
98-
'mdsAccounts',
99-
'isScrubbed'
100-
],
101-
'description': 'Class representing the Kusto Geneva legacy connection properties.'
81+
type: 'object',
82+
properties: {
83+
genevaEnvironment: {
84+
type: 'string',
85+
description: 'The Geneva environment of the geneva data connection.'
86+
},
87+
mdsAccounts: {
88+
type: 'array',
89+
description: 'The list of mds accounts of the geneva data connection.'
90+
},
91+
isScrubbed: {
92+
type: 'boolean',
93+
description: 'Indicates whether the data is scrubbed.'
94+
}
95+
},
96+
required: [
97+
'genevaEnvironment',
98+
'mdsAccounts',
99+
'isScrubbed'
100+
],
101+
'description': 'Class representing the Kusto Geneva legacy connection properties.'
102102
});
103103

104104
const genevaLegacyDataConnection = () => ({
105-
type: 'object',
106-
properties: {
107-
properties: {
108-
oneOf: [
109-
{
110-
$ref: '#/definitions/GenevaLegacyDataConnectionProperties'
111-
},
112-
{
113-
$ref: 'https://schema.management.azure.com/schemas/common/definitions.json#/definitions/expression'
114-
}
115-
],
116-
description: 'Geneva legacy data connection properties.'
105+
type: 'object',
106+
properties: {
107+
properties: {
108+
oneOf: [
109+
{
110+
$ref: '#/definitions/GenevaLegacyDataConnectionProperties'
117111
},
118-
kind: {
119-
type: 'string',
120-
enum: [
121-
'GenevaLegacy'
122-
]
112+
{
113+
$ref: 'https://schema.management.azure.com/schemas/common/definitions.json#/definitions/expression'
123114
}
124-
},
125-
required: [
126-
'kind'
127115
],
128-
description: 'Information about the Geneva legacy data connection.'
116+
description: 'Geneva legacy data connection properties.'
117+
},
118+
kind: {
119+
type: 'string',
120+
enum: [
121+
'GenevaLegacy'
122+
]
123+
}
124+
},
125+
required: [
126+
'kind'
127+
],
128+
description: 'Information about the Geneva legacy data connection.'
129129
});
130130

131131
const clusterDataConnections_childResource = () => ({
132-
$ref: '#/definitions/clusters_dataConnections_childResource'
132+
$ref: '#/definitions/clusters_dataConnections_childResource'
133133
});
134134

135135
export const postProcessor: SchemaPostProcessor = async (namespace: string, apiVersion: string, schema: any) => {
136-
// Handle cluster data connection
137-
if (apiVersionCompare(apiVersion, '2019-11-09') > -1){
138-
const clusterSubResources = schema.resourceDefinitions.clusters.properties.resources.items.oneOf;
139-
clusterSubResources.push(clusterDataConnections_childResource());
140-
schema.resourceDefinitions.clusters.properties.resources.items.oneOf = clusterSubResources;
141-
const clusterDataConnectionObject = clusterDataConnections(apiVersion);
142-
schema['resourceDefinitions']['clusters_dataConnections'] = clusterDataConnectionObject;
143-
clusterDataConnectionObject.properties.type.enum = ["Microsoft.Kusto/clusters/dataconnections"];
144-
schema.definitions.clusters_dataConnections_childResource = clusterDataConnectionObject;
145-
schema.definitions.GenevaDataConnectionProperties = genevaDataConnectionProperties();
146-
schema.definitions.GenevaDataConnection = genevaDataConnection();
147-
schema.definitions.GenevaLegacyDataConnectionProperties = genevaLegacyDataConnectionProperties();
148-
schema.definitions.GenevaLegacyDataConnection = genevaLegacyDataConnection();
149-
}
150-
151-
// Handle read only following database
136+
// Handle cluster data connection
137+
if (apiVersionCompare(apiVersion, '2019-11-09') > -1) {
138+
const clusterSubResources = schema.resourceDefinitions.clusters.properties.resources.items.oneOf;
139+
clusterSubResources.push(clusterDataConnections_childResource());
140+
schema.resourceDefinitions.clusters.properties.resources.items.oneOf = clusterSubResources;
141+
const clusterDataConnectionObject = clusterDataConnections(apiVersion);
142+
schema['resourceDefinitions']['clusters_dataConnections'] = clusterDataConnectionObject;
143+
clusterDataConnectionObject.properties.type.enum = ["Microsoft.Kusto/clusters/dataconnections"];
144+
schema.definitions.clusters_dataConnections_childResource = clusterDataConnectionObject;
145+
schema.definitions.GenevaDataConnectionProperties = genevaDataConnectionProperties();
146+
schema.definitions.GenevaDataConnection = genevaDataConnection();
147+
schema.definitions.GenevaLegacyDataConnectionProperties = genevaLegacyDataConnectionProperties();
148+
schema.definitions.GenevaLegacyDataConnection = genevaLegacyDataConnection();
149+
}
150+
// Handle read only following database
152151

152+
// TODO: Remove this workaround once https://github.com/Azure/autorest.azureresourceschema/pull/74 is merged
153+
const requiredArray = schema['resourceDefinitions']['clusters'].required
154+
if (requiredArray && Array.isArray(requiredArray)) {
155+
const index = requiredArray.indexOf('properties')
156+
if (index !== -1) {
157+
requiredArray.splice(index, 1)
158+
}
159+
}
153160
}

generator/processors/Microsoft.Storage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const postProcessor: SchemaPostProcessor = async (namespace: string, apiV
99
'extension_resourceDefinitions'
1010
].filter(scope => schema[scope])
1111

12+
// TODO: Remove this workaround once https://github.com/Azure/autorest.azureresourceschema/pull/74 is merged
1213
scopes.forEach(scope => {
1314
for (let key in schema[scope]) {
1415
const requiredArray = schema[scope][key].required

schemas/2018-09-07-preview/Microsoft.Kusto.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
"apiVersion",
7979
"location",
8080
"name",
81-
"properties",
8281
"sku",
8382
"type"
8483
],

schemas/2019-01-21/Microsoft.Kusto.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979
"apiVersion",
8080
"location",
8181
"name",
82-
"properties",
8382
"sku",
8483
"type"
8584
],

schemas/2019-05-15/Microsoft.Kusto.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393
"apiVersion",
9494
"location",
9595
"name",
96-
"properties",
9796
"sku",
9897
"type"
9998
],

schemas/2019-09-07/Microsoft.Kusto.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@
107107
"apiVersion",
108108
"location",
109109
"name",
110-
"properties",
111110
"sku",
112111
"type"
113112
],

schemas/2019-11-09/Microsoft.Kusto.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@
113113
"apiVersion",
114114
"location",
115115
"name",
116-
"properties",
117116
"sku",
118117
"type"
119118
],

schemas/2020-02-15/Microsoft.Kusto.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@
113113
"apiVersion",
114114
"location",
115115
"name",
116-
"properties",
117116
"sku",
118117
"type"
119118
],

schemas/2020-06-14/Microsoft.Kusto.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@
113113
"apiVersion",
114114
"location",
115115
"name",
116-
"properties",
117116
"sku",
118117
"type"
119118
],

schemas/2020-09-18/Microsoft.Kusto.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@
113113
"apiVersion",
114114
"location",
115115
"name",
116-
"properties",
117116
"sku",
118117
"type"
119118
],

0 commit comments

Comments
 (0)