Sort endpoints within resources - SmartDocs

Not applicable

Hi, I am trying to find a way to sort my SmartDocs endpoints within one resource in an order I define manually.

Is there any way to sort the endpoints? Can someone explain how to configure this?

Solved Solved
1 10 946
1 ACCEPTED SOLUTION

Interesting Question @jan.willem.hennink ,

I assume, you are talking about SmartDocs listing page "model-name/apis" page just like below one,

2820-screen-shot-2016-05-31-at-45146-pm.png

Yes, It's possible to change sort order & thanks to Drupal (Apigee Developer Portal is powered by famous open source cms Drupal). By default, they are sorted by creation date. You can change the order based on manual set weight.

Please find steps below to achieve same,

  • Download " Weight" 7.x contributed module from Drupal.org , Extract the zip file into sites/all/modules OR sites/all/modules/contrib folder.
  • Enable the module by navigating to "admin/modules" page as Developer Portal Administrator. Click on Save Configuration.

2821-screen-shot-2016-05-31-at-45819-pm.png

  • Navigate to "admin/structure/types/manage/smart_method/fields" , Add a new field called weight to the content type. See screenshot below for details. Click on Save -> Save Field Settings -> Choose Range as per need, I have selected 100 -> Save Settings.

2822-screen-shot-2016-05-31-at-50331-pm.png

  • Edit the SmartDocs view which you would like to custom sort , Remove Default "Post Date" sort field & Add "SmartMethod Weight" field & save the view.

2823-pjimage.jpg

  • Edit individual smartdocs method page to set weights to re-order them.

View solution in original post

10 REPLIES 10

Interesting Question @jan.willem.hennink ,

I assume, you are talking about SmartDocs listing page "model-name/apis" page just like below one,

2820-screen-shot-2016-05-31-at-45146-pm.png

Yes, It's possible to change sort order & thanks to Drupal (Apigee Developer Portal is powered by famous open source cms Drupal). By default, they are sorted by creation date. You can change the order based on manual set weight.

Please find steps below to achieve same,

  • Download " Weight" 7.x contributed module from Drupal.org , Extract the zip file into sites/all/modules OR sites/all/modules/contrib folder.
  • Enable the module by navigating to "admin/modules" page as Developer Portal Administrator. Click on Save Configuration.

2821-screen-shot-2016-05-31-at-45819-pm.png

  • Navigate to "admin/structure/types/manage/smart_method/fields" , Add a new field called weight to the content type. See screenshot below for details. Click on Save -> Save Field Settings -> Choose Range as per need, I have selected 100 -> Save Settings.

2822-screen-shot-2016-05-31-at-50331-pm.png

  • Edit the SmartDocs view which you would like to custom sort , Remove Default "Post Date" sort field & Add "SmartMethod Weight" field & save the view.

2823-pjimage.jpg

  • Edit individual smartdocs method page to set weights to re-order them.

This works great! Many thanks!

Anytime @jan.willem.hennink , Glad issue is resolved 🙂

Thanks Anil,

After enabling the Weight module...

  • This doesn't appear in my admin menu
    • “admin/structure/types/manage/smart_method/fields”
  • Do you mean
    • "admin/structure/taxonomy/smartdocs_models/fields?

Thanks

I am able to navigate there as an admin by going to: Home » Administration » Structure » Content types » SmartDocs Method, see this screenshot:

5810-screen-shot-2017-10-25-at-45302-pm.png

That looks right Chris. @Anil Sagar can you edit your answer to match the menu? Thanks


Hi @Anil Sagar

I have tried to add weight field to the SmartDoc Method as mentioned by you. But when I import my swagger I see all APIs wight field has 0 only. Am I missing anything. Also wanted to confirm about order of APIs. Will it take exact order based on swagger apis under paths? Please answer my question.

Regards,

Veera

Not applicable

Hi @Veera Prasad

When we configure new field in the smartdocs method for weight, there is an option for default value.

If you have set that to "0", in that case it will show 0 for all newly created smartdocs methods when we import the swagger.

As mentioned in the post at very end that,

"Edit individual smartdocs method page to set weights to re-order them."

We need to manually update the weight for each method that we write and also need to update the view which is used to sort the smartdocs methods when we render them.

Thanks,

Prathamesh

@Anil Sagar, @Prathamesh Kelaskar Is there any configuration at apigee. its should create smartdocs methods as per the order in swagger.yml so it will solve the issue without manually adding weights for each method after import of swagger.yml

@SANGAMESH Hooli

I believe that we can utilize few existing SmartDoc APIs to enhance this feature. For example, to update weight field value, we can actually utilize hook_smartdocs_method_node_presave. I am in the process of finding the solution on capturing path order from swagger. I will keep you posted with solution.

Regards,
Veera