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: /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 runtime API context\n\tvar json = apim.getvariable('message');\n\tconsole.error(\"json %s\", JSON.stringify(json.headers));\n\t\n\t//add a new attribute to the payload body \n\tjson.body.platform = 'Powered by IBM API Connect';\n\tapim.setvariable('message.body', json.body);\n\n\t//add a new response header\n\tjson.headers.platform = 'Powered by IBM API Connect';\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) otherwise: [] version: 1.0.0 catch: [] gateway: datapower-gateway consumes: - application/json