Customizing Smart Docs Summary Page

fishbd1
Participant II

I am attempting to replace the smart docs summary with a Swagger UI. I am in the process of adding the Drupal module https://www.drupal.org/project/swagger_ui_formatter to replace the smartdocs method listing.

The module creates a format field type called Swagger UI Formatter which renders the smart doc as seen below.

The Swagger UI Formatter field works within a node, however I'm trying to get it to render from a view (eventually the base view). After inserting that field type in the view, it breaks the view completely and makes it un-editable and makes it impossible to grab the PHP code in order to update the base view.

If any of the Drupal experts have any ideas on implementing the Swagger UI Formatter into the base view for smart docs it would be GREATLY appreciated.

@Anil Sagar
@Gitesh Koli

@Daniel Johnson


4429-smart-docs-view.png

4427-smart-docs-resource-summary.png

Solved Solved
0 6 571
1 ACCEPTED SOLUTION

Not applicable

@Dave: We have recently started playing with this module. I think it will take a bit more polish to get it into a production-ready state, but I think this is a good prospective alternative to the SmartDocs module, which can sometimes have performance issues for some customers.

One interesting difference between this module and SmartDocs is that the Swagger UI Formatter embeds a complete model in a single node, whereas SmartDocs creates a single node for each method within the model.

I'll try to take a look at embedding these fields in a view later this week. I'm curious: what's your use-case for embedding these in a view?

Also, I'm curious to hear how (if at all) you have gotten security models to work. I haven't fully explored them but I have heard through the grapevine that this module doesn't fully support them to the same degree that the Swagger UI on swagger.io does. This is an area which I have been planning on exploring when I get a few spare moments.

View solution in original post

6 REPLIES 6

Not applicable

@Dave: We have recently started playing with this module. I think it will take a bit more polish to get it into a production-ready state, but I think this is a good prospective alternative to the SmartDocs module, which can sometimes have performance issues for some customers.

One interesting difference between this module and SmartDocs is that the Swagger UI Formatter embeds a complete model in a single node, whereas SmartDocs creates a single node for each method within the model.

I'll try to take a look at embedding these fields in a view later this week. I'm curious: what's your use-case for embedding these in a view?

Also, I'm curious to hear how (if at all) you have gotten security models to work. I haven't fully explored them but I have heard through the grapevine that this module doesn't fully support them to the same degree that the Swagger UI on swagger.io does. This is an area which I have been planning on exploring when I get a few spare moments.

Daniel,

Thanks for the input.

The use case for embedding the Swagger UI in a view is that we want to keep the existing framework we have in place for discovering API's. We created "buckets" for discoverability based on Service Domain (Insurance, Banking, etc) that utilize a "base view". We then filter API's based on those domains from a menu item. API's->Browse->Banking. The menu target is then Service-Domain/Business or Utility, etc. In short we want to be able to filter API's based on business domain. Hope that makes sense.

We like that Swagger UI renders a complete model in a single node. We also like the look and feel of the Swagger UI much better than the smart docs. The Swagger I referenced Pet Insurance Quote was built by an Apigee person and it renders perfectly in Swagger UI, whereas we've had issues with other swagger docs rendering incorrectly in smart docs.

4431-menu.png

Hey @Daniel Johnson, @Gitesh Koli

I forgot to address your question regarding security models. I am getting an error message when attempting to display security models with this module. See attached image.

Also I have another question for you. If I wanted to remove the existing smart docs rendering from the base view, could I simply remove the fields security, body, base url, tags and verb from the smartdocs.views_default.inc? Not sure if that would have other implications I'm not aware of.

4443-security-model.png

@Dave @Daniel Johnson,

I'm also trying to render the swaggerUI format instead of smartdocs. Kindly let me know if you were able to do the same.

Thanks

Pratyush,

I ended up using the Drupal module Swagger UI Field Formatter - https://www.drupal.org/project/swagger_ui_formatter .

I created a custom view that renders a valid swagger file. (attachment 1) (https://developer.nationwide.com/swagger/Pet%20Insurance%20Quote%20V1 )

It allows you to add a field for the Swagger file and format it as Swagger UI Formatter. (attachment 2)

6208-pet-quote.png

6210-pet-quote-config.png

Hi Dave,

I was able to achieve the same view but I was having issues as my swagger is not public, but when I check the source page I see the URL of the file location in drupal sites/default/files directory as well as download it even if I have defined it as a private file in content. So is there any way to restrict the URL visibility in source or restricting the download on visiting the link.

I have attached the screenshot of your yaml file location. I'm seeing the same in my portal as well.

Thank you.file.png