forked from ibm-apiconnect/openid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweather-provider-api_1.0.0.yaml
184 lines (184 loc) · 5.69 KB
/
weather-provider-api_1.0.0.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
swagger: '2.0'
info:
title: Weather Provider API
version: 1.0.0
x-ibm-name: weather-provider-api
host: myweatherprovider.mybluemix.net
schemes:
- https
basePath: /
produces:
- application/json
paths:
/weather:
get:
responses:
'200':
description: 200 OK
/current:
get:
summary: Current Weather
parameters:
- name: zipcode
in: query
description: A valid 5-digit US zip code
required: true
type: string
responses:
'200':
description: Success
schema:
$ref: '#/definitions/Current'
/today:
get:
summary: Today's Weather
parameters:
- name: zipcode
in: query
description: A valid 5-digit US zip code
required: true
type: string
responses:
'200':
description: Profile information for a user
schema:
$ref: '#/definitions/Today'
definitions:
Today:
type: object
properties:
zip:
type: string
hi:
type: integer
lo:
type: integer
nightHumidity:
type: integer
city:
type: string
state:
type: string
dayHumidity:
type: integer
Current:
type: object
properties:
zip:
type: string
temperature:
type: integer
humidity:
type: integer
city:
type: string
state:
type: string
x-ibm-configuration:
enforced: true
testable: true
phase: realized
cors:
enabled: true
assembly:
execute:
- operation-switch:
title: operation-switch
case:
- operations:
- verb: get
path: /current
execute:
- invoke:
title: invoke-current
timeout: 60
verb: GET
cache-response: protocol
cache-ttl: 900
version: 1.0.0
target-url: >-
https://myweatherprovider.mybluemix.net/current?zipcode=$(request.parameters.zipcode)
- gatewayscript:
title: gatewayscript
version: 1.0.0
source: "\t//get the payload\n\tvar json = apim.getvariable('message');\n\tconsole.info(\"json %s\", JSON.stringify(json));\n\n\t//code to inject new attribute \n\tif (json.body && json.status.code == '404') {\n\t\tconsole.error(\"throwing apim error %s\", JSON.stringify(json.status.code));\n\t\tapim.error('ConnectionError', 500, 'Service Error', 'Failed to retrieve data');\n\t\t\n\t}\n\telse {\n\t\tjson.body.platform = 'Powered by IBM API Connect';\n\t\tjson.headers.platform = 'Powered by IBM API Connect';\n\t}\n\n\t//set the payload\n\tapim.setvariable('message.body', json.body);\n\tapim.setvariable('message.headers', json.headers);"
- operations:
- verb: get
path: /today
execute:
- invoke:
title: invoke-today
timeout: 60
verb: GET
cache-response: protocol
cache-ttl: 900
version: 1.0.0
target-url: >-
https://myweatherprovider.mybluemix.net/today?zipcode=$(request.parameters.zipcode)
- operations:
- verb: get
path: /weather
execute:
- invoke:
title: get-jwk-key
timeout: 60
verb: GET
cache-response: time-to-live
cache-ttl: 900
version: 1.0.0
target-url: 'https://ozairs.auth0.com/.well-known/jwks.json'
output: rsa256-key
- gatewayscript:
title: gatewayscript
version: 1.0.0
source: "\tvar rsa256Key = apim.getvariable('rsa256-key');\n\tapim.setvariable('jwk-key', JSON.stringify(rsa256Key.body.keys[0]));\n\t\n\tconsole.error('jwk key %s', apim.getvariable('jwk-key'));\n\t\n\t\tconsole.error('jwt %s', apim.getvariable(''));"
- jwt-validate:
title: jwt-validate
jwt: request.headers.authorization
output-claims: decoded.claims
version: 1.0.0
iss-claim: .*\.auth0\.com\/
aud-claim: .*\.apiconnect\.com
jws-jwk: jwk-key
- gatewayscript:
title: gatewayscript
version: 1.0.0
source: >-
apim.setvariable('message.body',
apim.getvariable('decoded.claims'));
otherwise: []
version: 1.0.0
catch:
- errors:
- ConnectionError
- RuntimeError
execute:
- set-variable:
title: Rewrite Error
actions:
- set: message.body
value: '{"message": "Error occurred during search operation."}'
version: 1.0.0
gateway: datapower-gateway
consumes:
- application/json
securityDefinitions:
api-key-1:
type: apiKey
description: ''
in: header
name: X-IBM-Client-Id
oauth-accesscode:
type: oauth2
description: ''
flow: accessCode
authorizationUrl: 'https://$(api.endpoint.address):9443/oauth2/authorize'
scopes:
weather: ''
openid: ''
tokenUrl: 'https://$(api.endpoint.address):9443/oauth2/token'
security:
- api-key-1: []
oauth-accesscode:
- weather
- openid