API names with Swagger

mrios
Participant IV

Hi,

We are using Swagger 2.0 through springfox framework. This framework generate a Swagger - JSON file for each project that we have. The problem that we are facing is that the Developer Portal seems to generate the method name using the operationId of the swagger-json file and this framework generate method names with the convention [java_method_name]+Using+[HTTP verb].

As a result our API methods name looks weird, for example: userByIdUsingGET or getVMsUsingGET.

Is there a way that the Developer Portal use the partial url as the swagger-ui use instead of the method name generated by the operationId?

This is how the swagger-ui looks like

1580-screen-shot-2015-12-01-at-14429-pm.png

And this is what we get with the same swagger-json file in the Dev Portal

1581-screen-shot-2015-12-01-at-14454-pm.png

Thanks,

Matias

4 11 2,713
11 REPLIES 11

Hi @Matias

I agree with you. I already reported it in the following post.

Apigee Developer Portal - Smartdocs - Renders verb name in the title

I think developer portal should use vendor extension of Swagger or path of each endpoint. Because an operationId is used for many purposes.

Sokichi

@Sokichi Fujita , See below answer to do same using Drupal Views configuration in developer portal.

PS: Agree, its not straight forward, We will try to make it as a configurable option in devportal if possible. @harsh @Marsh Gardiner FYI

Hi @Sokichi Fujita

I was searching for a similar post but I couldn't find your. Thanks for pointed out!

+1 to the vendor extension, that would be great.

Dear @Matias ,

Great Question, Yes, You can able to do that in Apigee Edge Developer Portal without need to change your Swagger Spec. Follow below instructions step by step to achieve same.

Step 1 :

Edit your SmartDocs listing page view. Login as Developer Portal Administrator & Navigate to APIs listing page and hover on top of header to see a gear like on right side. Click on that icon & Click On Edit View.

1583-screen-shot-2015-12-02-at-113733-am.png

Step 2 :

Now, You will see "View" Edit screen like below.

1584-screen-shot-2015-12-02-at-115811-am.png

Step 3:

Click on Fields Content Title & Then Click on Remove.

1585-screen-shot-2015-12-02-at-120105-pm.png

1586-screen-shot-2015-12-02-at-120114-pm.png

Add a new field called , Content : Nid , Uncheck Label, Check Exclude from Display

Reorder the fields (drag & drop), & make sure nid field is on top.

Step 4 :

Add a new field called , Resource path , Click on Add Link next to fields header, & search for resource path, select Content:Resource Path, Appears in smart_method

1587-screen-shot-2015-12-02-at-120317-pm.png

Uncheck Label, & Check "Exclude From Display"

Open Rewrite Results, Check Output this field as a link , update link path to node/[nid] & Click Apply.

Step 5 : Reorder the fields (drag & drop), & make sure resource path field is below the nid.

Click on Arrow mark , next to Add to reorder fields,

Bring it to top, just below the nid & Click on Apply

Step 6 :

Click on global text , and change the replacement pattern token from [title] to [field_smart_method_resource_path] in the text area.

Click on Apply

Step 7 :

Save your view.

That's it, see the result below.

Thanks @Anil Sagar,

Those were some really easy to follow steps kudos to that!

So, now, the bad news is that I did exactly the same but I can't see the resource url instead of the method name. I cleared all the caches and it shows me the same.

Here is the Model index page with the change

1592-screen-shot-2015-12-02-at-30136-pm.png

Here is the global custom change

1593-screen-shot-2015-12-02-at-30230-pm.png

and I also tried to change the Front-page Block adding the same Resource path and changing the "Global: Custom text".

Any idea what might be the problem?

Thanks!

@Matias

I see that the view you are editing is not a page view, seems like it's a block view. Did you click on wheel icon in the listing page and then view edit ? Are you on cloud / on prem ? Can you share the developer portal url if you are on cloud ?

In your screenshot, second column says block settings instead of page settings.

@Anil Sagar

You are right, I was editing the view through Structure --> View and I was searching the page with the same name, but apparently is not the page is the block.

I did that because when I go to the page setting using the gear our view is quite different.

1601-screen-shot-2015-12-03-at-113659-am.png

We don't have the fields that you have nor the same header as you.

We have the on-prem version OPDK-4.15.07.00 and unfortunately is not available on-line.

Should I add the fields by hand? if that's the case how should I do it? because there is no add for fields.

Any idea why we don't have the fields by default?

Thanks,

@Matias , Got it. Above instructions are for cloud version. It might be slightly different in the case of onPrem. Let me do some research on onPrem version & get back to you.

Hi @Anil Sagar

Thank you.But can you click the title (/forecastrss) in the above screen?

I tried it in my on premise environment. However each link of title is lost after these operations. So anyone can't go to the detail page of API. Or did I miss any operations?

1613-smartdocs-title.png

Good catch @Sokichi Fujita , I missed to update documentation / make it as a link, Let me update the above answer. Are you able to see path in place of title ?

@Sokichi Fujita , Updated step 3, step 4 with further instructions to fix the link issue. Please keep us posted.