Skip to content

Commit c15f339

Browse files
shreyanshnShreyansh Nawlakha
authored andcommitted
Check Resource Name added to swagger (Azure#9185)
* Check Resource Name added to swagger * spellcheck and prettier check fixed * fixes * prettier check and x-ms fixes * added schema for resource name * fixes * description added to resourcename * added changes to all api versions * default response added * prettier checl * default response changed * removed 2016-06-01 api * override errors * file moved to examples * single override * reverting * override policyclient Co-authored-by: Shreyansh Nawlakha <[email protected]>
1 parent b56c1ad commit c15f339

File tree

13 files changed

+801
-0
lines changed

13 files changed

+801
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"parameters": {
3+
"body": [
4+
{
5+
"Name": "isxbox",
6+
"Type": "ResourceProviderTestHost/TestResourceType"
7+
}
8+
],
9+
"api-version": "2015-11-01"
10+
},
11+
"responses": {
12+
"200": {
13+
"body": {
14+
"name": "isxbox",
15+
"type": "ResourceProviderTestHost/TestResourceType",
16+
"status": "Allowed"
17+
}
18+
}
19+
}
20+
}

specification/resources/resource-manager/Microsoft.Resources/stable/2015-11-01/subscriptions.json

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,46 @@
145145
"nextLinkName": "nextLink"
146146
}
147147
}
148+
},
149+
"/providers/Microsoft.Resources/checkResourceName": {
150+
"post": {
151+
"tags": [
152+
"Tenants"
153+
],
154+
"operationId": "checkResourceName",
155+
"description": "A resource name is valid if it is not a reserved word, does not contains a reserved word and does not start with a reserved word",
156+
"summary": "Checks resource name validity",
157+
"consumes": [
158+
"application/json"
159+
],
160+
"parameters": [
161+
{
162+
"$ref": "#/parameters/CheckResourceNameParameter"
163+
},
164+
{
165+
"$ref": "#/parameters/ApiVersionParameter"
166+
}
167+
],
168+
"responses": {
169+
"200": {
170+
"description": "OK - Returns status as allowed or not.",
171+
"schema": {
172+
"$ref": "#/definitions/CheckResourceNameResult"
173+
}
174+
},
175+
"default": {
176+
"description": "Error response saying resource name is invalid",
177+
"schema": {
178+
"$ref": "#/definitions/ErrorResponse"
179+
}
180+
}
181+
},
182+
"x-ms-examples": {
183+
"Check validity for a resource name.": {
184+
"$ref": "./examples/CheckResourceName.json"
185+
}
186+
}
187+
}
148188
}
149189
},
150190
"definitions": {
@@ -277,9 +317,82 @@
277317
"nextLink"
278318
],
279319
"description": "Tenant Ids information."
320+
},
321+
"ResourceName": {
322+
"description": "Name and Type of the Resource",
323+
"required": [
324+
"name",
325+
"type"
326+
],
327+
"properties": {
328+
"name": {
329+
"description": "Name of the resource",
330+
"type": "string"
331+
},
332+
"type": {
333+
"type": "string",
334+
"description": "The type of the resource"
335+
}
336+
}
337+
},
338+
"ErrorResponse": {
339+
"description": "Error response.",
340+
"properties": {
341+
"error": {
342+
"$ref": "#/definitions/ErrorDefinition",
343+
"description": "The error details."
344+
}
345+
}
346+
},
347+
"ErrorDefinition": {
348+
"description": "Error description and code explaining why resource name is invalid.",
349+
"properties": {
350+
"message": {
351+
"type": "string",
352+
"description": "Description of the error."
353+
},
354+
"code": {
355+
"type": "string",
356+
"description": "Code of the error."
357+
}
358+
}
359+
},
360+
"CheckResourceNameResult": {
361+
"properties": {
362+
"name": {
363+
"description": "Name of Resource",
364+
"type": "string"
365+
},
366+
"type": {
367+
"description": "Type of Resource",
368+
"type": "string"
369+
},
370+
"status": {
371+
"description": "Is the resource name Allowed or Reserved",
372+
"type": "string",
373+
"enum": [
374+
"Allowed",
375+
"Reserved"
376+
],
377+
"x-ms-enum": {
378+
"name": "ResourceNameStatus",
379+
"modelAsString": true
380+
}
381+
}
382+
},
383+
"description": "Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word"
280384
}
281385
},
282386
"parameters": {
387+
"CheckResourceNameParameter": {
388+
"description": "Resource object with values for resource name and resource type",
389+
"in": "body",
390+
"name": "Resource Name Definition",
391+
"schema": {
392+
"$ref": "#/definitions/ResourceName"
393+
},
394+
"x-ms-parameter-location": "method"
395+
},
283396
"ApiVersionParameter": {
284397
"name": "api-version",
285398
"in": "query",
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"parameters": {
3+
"body": [
4+
{
5+
"Name": "isxbox",
6+
"Type": "ResourceProviderTestHost/TestResourceType"
7+
}
8+
],
9+
"api-version": "2016-06-01"
10+
},
11+
"responses": {
12+
"200": {
13+
"body": {
14+
"name": "isxbox",
15+
"type": "ResourceProviderTestHost/TestResourceType",
16+
"status": "Allowed"
17+
}
18+
}
19+
}
20+
}

specification/resources/resource-manager/Microsoft.Resources/stable/2016-06-01/subscriptions.json

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,46 @@
162162
"nextLinkName": "nextLink"
163163
}
164164
}
165+
},
166+
"/providers/Microsoft.Resources/checkResourceName": {
167+
"post": {
168+
"tags": [
169+
"Tenants"
170+
],
171+
"operationId": "checkResourceName",
172+
"description": "A resource name is valid if it is not a reserved word, does not contains a reserved word and does not start with a reserved word",
173+
"summary": "Checks resource name validity",
174+
"consumes": [
175+
"application/json"
176+
],
177+
"parameters": [
178+
{
179+
"$ref": "#/parameters/CheckResourceNameParameter"
180+
},
181+
{
182+
"$ref": "#/parameters/ApiVersionParameter"
183+
}
184+
],
185+
"responses": {
186+
"200": {
187+
"description": "OK - Returns status as allowed or not.",
188+
"schema": {
189+
"$ref": "#/definitions/CheckResourceNameResult"
190+
}
191+
},
192+
"default": {
193+
"description": "Error response saying resource name is invalid",
194+
"schema": {
195+
"$ref": "#/definitions/ErrorResponse"
196+
}
197+
}
198+
},
199+
"x-ms-examples": {
200+
"Check validity for a resource name.": {
201+
"$ref": "./examples/CheckResourceName.json"
202+
}
203+
}
204+
}
165205
}
166206
},
167207
"definitions": {
@@ -338,6 +378,70 @@
338378
],
339379
"description": "Tenant Ids information."
340380
},
381+
"ResourceName": {
382+
"description": "Name and Type of the Resource",
383+
"required": [
384+
"name",
385+
"type"
386+
],
387+
"properties": {
388+
"name": {
389+
"description": "Name of the resource",
390+
"type": "string"
391+
},
392+
"type": {
393+
"type": "string",
394+
"description": "The type of the resource"
395+
}
396+
}
397+
},
398+
"CheckResourceNameResult": {
399+
"properties": {
400+
"name": {
401+
"description": "Name of Resource",
402+
"type": "string"
403+
},
404+
"type": {
405+
"description": "Type of Resource",
406+
"type": "string"
407+
},
408+
"status": {
409+
"description": "Is the resource name Allowed or Reserved",
410+
"type": "string",
411+
"enum": [
412+
"Allowed",
413+
"Reserved"
414+
],
415+
"x-ms-enum": {
416+
"name": "ResourceNameStatus",
417+
"modelAsString": true
418+
}
419+
}
420+
},
421+
"description": "Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word"
422+
},
423+
"ErrorResponse": {
424+
"description": "Error response.",
425+
"properties": {
426+
"error": {
427+
"$ref": "#/definitions/ErrorDefinition",
428+
"description": "The error details."
429+
}
430+
}
431+
},
432+
"ErrorDefinition": {
433+
"description": "Error description and code explaining why resource name is invalid.",
434+
"properties": {
435+
"message": {
436+
"type": "string",
437+
"description": "Description of the error."
438+
},
439+
"code": {
440+
"type": "string",
441+
"description": "Code of the error."
442+
}
443+
}
444+
},
341445
"Operation": {
342446
"description": "Microsoft.Resources operation",
343447
"type": "object",
@@ -395,6 +499,15 @@
395499
"description": "The ID of the target subscription.",
396500
"x-ms-parameter-location": "method"
397501
},
502+
"CheckResourceNameParameter": {
503+
"description": "Resource object with values for resource name and resource type",
504+
"in": "body",
505+
"name": "Resource Name Definition",
506+
"schema": {
507+
"$ref": "#/definitions/ResourceName"
508+
},
509+
"x-ms-parameter-location": "method"
510+
},
398511
"ApiVersionParameter": {
399512
"name": "api-version",
400513
"in": "query",
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"parameters": {
3+
"body": [
4+
{
5+
"Name": "isxbox",
6+
"Type": "ResourceProviderTestHost/TestResourceType"
7+
}
8+
],
9+
"api-version": "2018-06-01"
10+
},
11+
"responses": {
12+
"200": {
13+
"body": {
14+
"name": "isxbox",
15+
"type": "ResourceProviderTestHost/TestResourceType",
16+
"status": "Allowed"
17+
}
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)