WSO2 API Manager 3.2 - rewrite resources - url-rewriting

I would like to rewrite parameters in the resources of APIs in publisher.
I need to rewrite resource /question?$top=parameter1&$select=parameter2&$filter=parameter3 to /question/parameter3?$top=parameter1&$select=parameter2.
Could you please advise?
Thanks.

You can edit the resource by editing the relevant Swagger definition. Navigate to the API Definition section in the left panel in Publisher Portal, edit the resource and update the Swagger definition with the required changes to the resource.
As per the question, you need to add paramter3 as path parameter and remove one query parameter. You can use the following swagger segment to set path parameter to the resource.
parameters:
- name: parameter3
in: path
required: true
schema:
type: string

Related

Cannot define shared resource with custom values in TeamCity 10.0.2

There are 3 options available for shared resource type:
Infinite resource
Resource with quota
Resource with custom values
I select Resource with custom values, define them in Custom values field and then save the settings. However, when I open this resource for edit, I see that the resource type went back to "Infinite resource" value.
Is this a bug or feature and does that affect functionality?

Swagger Codegen JMeter Test data template

I am generating Jmeter's jmx file from a swagger definition, the JMX and test data CSV that gets generated seems pretty useless, it has no parameter information as to what the API expected, no http status code to response mapping information etc.
You can take any definition file, to reproduce this:
go to http://editor.swagger.io/#/
open any example from the file menu
From the generate client menu, click on Jmeter
What I expected was a JMX with the entire skeleton of the API so that the QA people don't have to worry about that and focus only on tests.
All the clients that I produce for other languages/tools are good enough to go except Jmeter, am I doing anything wrong here?
I generated JMeter (JMX) for different APIs and I got it to work, though a few issues and caveats.
First it generates
User Defined Variables to substitute in Host, Port, testCases, csvFileName
a JMX per API
a Thread Group per Method (POST, GET, .. )
a HTTP Header Manager per thread group, blank but useful to be in there.
HTTP Sampler for each request
Loading of CSV Data for filling parameter values
HTTP Status Assertion which is validated on error code defined in CSV file
Caveats and Issues
It does not keep your host from config, it replaces with local host. You must change it or pass it in via command line
It uses a default port of 8080, this caused me some grief as well.
The loop count is controlled by variable, testCases. However there is a bug in swagger-code-gen template for JMeter if you want to pass this in via the command line
testCases variable has a bug in the template it defines testCases as ${__P(host,10)} but it should be ${__P(testCases,10)}
GET Parameters are fill with 0 instead of ${variable_name}, this is from the template in swagger codegen. I have a fix in my fork that I have tested. The other option is just to fix it in the JMX file
Original
And after editing Parameters
Example Swagger that works
The following is the Swagger file I used (modified from echo) and the generated (with modification for Parameters) JMX. I have tested this JMX using RedLine13 Example Test and passing the parameters as required. Passing in parameters
-JtestCases=50
-Jhost=mazimi-prod.apigee.net
-Jport=80
And here is the example Yaml
---
swagger: '2.0'
info:
version: 1.0.0
title: Echo
description: |
#### Echos back every URL, method, parameter and header
Feel free to make a path or an operation and use **Try Operation** to test it. The echo server will
render back everything.
schemes:
- http
host: mazimi-prod.apigee.net
basePath: /echo
paths:
/{id}:
get:
parameters:
- name: id
in: path
description: ID
type: string
required: true
- name: user
in: query
description: name
type: string
required: true
- name: location
in: query
description: location
type: string
required: true
responses:
200:
description: Echo GET
Updated JMEter template in Swagger CodeGen
Since there are a few issues for making this work seamless within SwaggerCode Gen i created an issue and pull request. If you need to use it sooner the fork is over here https://github.com/richardfriedman/swagger-codegen/commit/5aff601eaccf67ec44bb681816d40a25e5aa20a3

Resource name with sub resource name in AWS HTTP end point

I have gone through this document and created an API , mapped to my lambda function and its working fine .Now i need to add more path parameter to my URL rather than '/mydemoresource' (Eg :-/mydemoresource/sub-resource.json) but AWS not allowing to give / as resource name.Any suggestion ,thanks in advance
/ is automatically setup as the root resource when setting up a new API Gateway. You can create a new method at the root level.
When published, the API Gateway includes the stage as part of the URL. In case you're referring to that, you can use custom domain names and add an API mapping to avoid the stage name to be included in the client visible URL.

REST Web API URL to update a resource property

To update the resource i have exposed following reset web api url -
http://server.com/api/v1/{companyid}/resources/{resourceid}
and request body contains the resource to be updated.
I have also exposed a seperate API to update a property of same resource. From business rule perspective this is special property and cannot be updated/retrieved along with normal resource api.
So using following url to expose separate api as below -
http://server.com/api/v1/{companyid}/resources/{resourceid}/property?propertyKey=propertyValue
this does not sound good. Is there better approach?
Answer from the comments for others
PUT api/v1/{companyid}/resources/{resourceid}/{property} with the Body containing the value of the property is one way.
PUT api/v1/{companyid}/resources/{resourceid}/{property}/{propertyvalue} is another way if you want the value entirely in the URL.
Of course, http://server.com/api/v1/{companyid}/resources/{resourceid}/property?propertyKey=propertyValue is also probably fine.
As #David-Brabant mentioned don't version your API's in the URL

Adding second parameter to web service URL

I'm using the following moviefone web service in one of my Android applications:
http://gateway.moviefone.com/
The user enters his zip code, and the following XML data is used to get his nearby movie theaters and movies.
http://www.moviefone.com/search/19087?format=xml
My question is, how do you add the parameter for changing the date of the showtimes? That XML only contains movie information for the current date. The web service gateway page says: "params: zip/id= count= date=YYYYMMDD"
I tried adding "date=20120208" to the end of the URL but it didn't work.
Use a & to separate multiple parameters:
http://www.moviefone.com/search/19087?format=xml&date=20120208
Separate parameters with an &

Resources