Skip to content

Commit 40a910a

Browse files
mhruskajakubtischler
authored andcommitted
Update rest_extract to use OAS3
1 parent 2f3d924 commit 40a910a

File tree

5 files changed

+131
-170
lines changed

5 files changed

+131
-170
lines changed

rest_extract/apply_templates.py

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def apply_template(spec_file, template, model):
2727

2828
elif model == 'fa2':
2929

30-
spec_yaml['securityDefinitions'] = template_yaml['securityDefinitions']
30+
spec_yaml['components']['securitySchemes'] = template_yaml['components']['securitySchemes']
3131
spec_yaml['security'] = template_yaml['security']
3232
spec_yaml['tags'] = template_yaml['tags'] + spec_yaml['tags']
3333
for p in template_yaml['paths']:
@@ -37,26 +37,14 @@ def apply_template(spec_file, template, model):
3737
#nothing specific, already set Info above.
3838
pass
3939

40-
# delete the example offset of 10
41-
# todo: Open Jira for this one to fix in upstream template
42-
try:
43-
del spec_yaml['parameters']['Offset']['x-example']
44-
except KeyError:
45-
pass
46-
47-
# some templates have host set to [array]
48-
if 'host' in spec_yaml:
49-
del spec_yaml['host']
50-
51-
# some templates list http & https some list https
52-
# we want just http, which it will use by default when not there
53-
if 'schemes' in spec_yaml:
54-
del spec_yaml['schemes']
40+
# some templates have servers set to "https://[array]/" and "http://[array]/"
41+
# we want just http, which it will use by default when not there, and we don't want the [array]
42+
if 'servers' in spec_yaml:
43+
del spec_yaml['servers']
5544

5645
# Sort spec_yaml dict so the output text puts consistent information at the top
5746
sort_order = [
58-
'swagger', 'info', 'host', 'basePath', 'schemes', 'securityDefinitions', 'security',
59-
'consumes', 'produces', 'paths', 'definitions', 'parameters', 'responses', 'tags', 'externalDocs'
47+
'openapi', 'info', 'servers', 'security', 'paths', 'components', 'tags'
6048
]
6149

6250
sorted_spec_yaml = {key: spec_yaml[key] for key in sort_order if key in spec_yaml}
@@ -83,7 +71,7 @@ def main():
8371

8472

8573
spec_directory = os.path.join(project_dir, "html", "specs")
86-
original_spec_directory = os.path.join(project_dir, "definitions", "oas2.0")
74+
original_spec_directory = os.path.join(project_dir, "definitions", "oas3.x")
8775

8876
with open(os.path.join(script_path, "fb_template.yaml"), encoding='utf-8') as f:
8977
fb_template_yaml = yaml.safe_load(f)

rest_extract/fa2_template.yaml

Lines changed: 55 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
swagger: "2.0"
2+
openapi: "3.0.1"
33
info:
44
title: Pure FlashArray API 2.0
55
version: "1.0"
@@ -19,16 +19,6 @@ info:
1919
###
2020
2121
Intro to how OAuth2 works with the 2.0 version: [Intro](https://support.purestorage.com/FlashArray/PurityFA/Purity_FA_REST_API/Reference/REST_API_2.0_Authentication_Guide)
22-
23-
securityDefinitions:
24-
OAuth2-Bearer-Token:
25-
type: apiKey
26-
in: header
27-
name: Authorization
28-
X-Auth-Token:
29-
type: apiKey
30-
in: header
31-
name: x-auth-token
3222
3323
security:
3424
- OAuth2-Bearer-Token: []
@@ -57,24 +47,22 @@ paths:
5747
5848
openssl rsa -in private.pem -outform PEM -pubout -out public.pem
5949
responses:
60-
200:
61-
description: "Token Generated"
62-
schema:
63-
type: object
64-
properties:
65-
private_key:
66-
type: string
67-
description: Private key in PEM format.
68-
public_key:
69-
type: string
70-
description: Public key in PEM format.
50+
"200":
51+
description: Token Generated
52+
content:
53+
application/json:
54+
schema:
55+
type: object
56+
properties:
57+
private_key:
58+
type: string
59+
description: Private key in PEM format.
60+
public_key:
61+
type: string
62+
description: Public key in PEM format.
7163
tags: [Auth Helpers]
7264
/oauth2_token_from_private_key:
7365
post:
74-
consumes:
75-
- "text/plain"
76-
produces:
77-
- "application/json"
7866
description: |-
7967
Authenticates to Flasharray, This returns a token_id (think session id), from an existing API Client,
8068
This is not part of the FlashArray API, it's a helper endpoint making it easy to generate an
@@ -83,52 +71,68 @@ paths:
8371
of what is happening.
8472
8573
Copy the output value, Authorization header, and then click on the green Authorize button at the
86-
top of the page. Paste in the value into
74+
top of the page. Paste in the value into
8775
responses:
88-
200:
89-
description: "Token Generated"
90-
schema:
91-
type: object
92-
properties:
93-
Authorization:
94-
type: string
95-
description: An OAuth bearer token to be used in the Authorization header for authorization to API endpoints.
96-
description:
97-
type: string
98-
desciption: How to use token
99-
100-
example: {"username":"pureuser"}
76+
"200":
77+
description: Token Generated
78+
content:
79+
application/json:
80+
schema:
81+
type: object
82+
properties:
83+
Authorization:
84+
type: string
85+
description: An OAuth bearer token to be used in the Authorization header for authorization to API endpoints.
86+
description:
87+
type: string
88+
description: How to use token
89+
example: {"username":"pureuser"}
90+
x-codegen-request-body-name: private_key
10191
tags: [Auth Helpers]
10292
parameters:
10393
- name: issuer_name
10494
in: header
105-
type: string
95+
schema:
96+
type: string
10697
description: Issuer value displayed in the FlashArray API
10798
Registration page or pureapiclient list ) by default it's the same name as API Client
10899

109100
- name: client_id
110101
in: header
111-
type: string
102+
schema:
103+
type: string
112104
description: Client Id value displayed in the FlashArray API
113105
Registration page or pureapiclient list
114106

115107
- name: key_id
116108
in: header
117-
type: string
109+
schema:
110+
type: string
118111
description: Key Id value displayed in the FlashArray API
119112
Registration page or pureapiclient list
120113

121114
- name: username
122115
in: header
123-
type: string
124-
description: The name of a valid user on the FlashArray that will be authenticated to.
125-
126-
- name: private_key
127-
required: true
128-
in: body
129-
schema:
116+
schema:
130117
type: string
131-
description: Private key in PEM format that was used to create the Public key for this API Client specified as the issuer in this call.
118+
description: The name of a valid user on the FlashArray that will be authenticated to.
119+
requestBody:
120+
description: Private key in PEM format that was used to create the Public key for this API Client specified as the issuer in this call.
121+
content:
122+
text/plain:
123+
schema:
124+
type: string
125+
required: true
126+
components:
127+
securitySchemes:
128+
OAuth2-Bearer-Token:
129+
type: apiKey
130+
name: Authorization
131+
in: header
132+
X-Auth-Token:
133+
type: apiKey
134+
name: x-auth-token
135+
in: header
132136

133137

134138
tags:

rest_extract/fa_template.yaml

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)