How Can I Make Spring Rest Docs Look Like Swagger? - spring-restdocs

I have started to use Spring Rest Docs for a project but other APIs in the company are still using Swagger/OpenAPI which has led to a style inconsistency.
The usual Swagger view (e.g. https://petstore.swagger.io) has collapsible sections for each url and CSS colouring GET/POST/PUT/DELETE etc.
I should be able to customise the asciidoctor with a line in the adoc
:stylesheet: custom.css
Is there an existing template for Spring Rest Docs that gives an output similar to what the default Swagger output looks like?
Can you add javascript to the asciidoctor output to animate some of the documentation like collapsible url sections?

This is really any Asciidoctor question so you might want to tag it as such.
Is there an existing template for Spring Rest Docs that gives an output similar to what the default Swagger output looks like?
Not that I am aware of.
Can you add javascript to the asciidoctor output to animate some of the documentation like collapsible url sections?
Yes, you can add JavaScript to the HTML that's generated by Asciidoctor. One approach is described in the answers to this question. Another approach is to use a DocinfoProcessor to inject the JavaScript into the <head> of the generated HTML. One advantage of the latter approach is that it allows the functionality to be packaged as a dependency and reused. You can see an example of a fairly simple DocinfoProcessor here.

Take a look at this Github project: https://github.com/ePages-de/restdocs-api-spec
A few teams at my company are using this to generate OpenAPI documentation from our Sprint Rest Doc tests.

Related

Best way how to publish OpenAPI document on GitHub (readme.md)?

I have a project hosted on GitHub. To document the API I am using the OpenAPI spec. Now I want to add a link on readme.md (on GitHub) that refers my visitors to the OpenAPI document for good user experience.
Far as I see I have two solutions:
http://editor.swagger.io/?raw=https://raw.githubusercontent.com/path/to/file.yaml
https://app.swaggerhub.com/apis/(username)/(api-name)/(api-version)
Both approaches are working, but they both open with an editor on left side that shows the content of YAML file and is, IMHO, wasting a significant screen space. Not really what I want. Is there an option to display the OpenAPI document without editor opened? Just similiar what is done for https://petstore.swagger.io/ which comes without editor opened.
Or ... is there maybe an option available to display the OpenAPI document on GitHub directly?
Thanks, Christoph
If you use SwaggerHub, replace /apis/ with /apis-docs/ in the URL to view just the API docs without the editor part. For example:
https://app.swaggerhub.com/apis-docs/swagger-hub/registry-api/1.0.47
Or if your OpenAPI definition is hosted elsewhere (e.g. on GitHub), you can use
https://petstore.swagger.io/?url=https://path/to/file.yaml
to load it into the public Swagger UI demo. Swagger UI renders API docs without the editor part.

Using a template in struct plugin

The struct plugin is nice for managing structured data. But so far the only way I found to present the data for one single entry is a simple automatically generated table at the top of the page followed by the content of the entrys wiki text. Since I need the single entry pages to look better, I want to replace the simple table with something more pleasing to the eye like a template page that gets included into the page itself using {page>_mytemplate}.
The mytemplate wiki page might look like this:
==== STRUCTFIELD_TITLE ====
The STRUCTFIELD_NAME is a STRUCTFIELD_CLASSIFICATION consisting
of STRUCTFIELD_INGREDIENTS.
"STRUCTFIELD_*" should be replaced with the fields defined in the schema of course.
The wiki page of the single entry should include the template page as mentioned above with {page>mytemplate}.
So my question in essence is: How to include single fields of a schema into a wiki page as template variables, and can this be further automated using one "template wiki page" that gets included via the {page>...} command?
Found a solution. It is discussed in detail here: https://github.com/cosmocode/dokuwiki-plugin-struct/issues/145
In a nutshell: There is a version of the Struct plugin which includes all the functionality needed: https://github.com/iainhallam/dokuwiki-plugin-struct/tree/feature/value

How to define custom wicket tag

I could not find a wicket tag like wicket:include? Can anyone suggest me anything? I want to include/inject raw source into html files? If there is no such utility, any suggestions to develop it?
update
i am looking for sth like jsp:include. this inclusion is expected to be handled on the server side.
To do this, you'll need to implement your own IComponentResolver.
This blog article shows an example somewhat resembling what you're after.
Is it raw markup that you want to include, or Wicket content?
If it's raw markup, even a simple Label can do that for you. If you call setEscapeModelStrings( false), the string value of the model will be copied straight in the markup. (Watch out for potential XSS attacks though.)
"Including" Wicket markup is done via Panels (or occasionally Fragments)
Update: If you add more detail about the actual problem you need to solve, there's a good chance that we can find a more "wickety" solution, after all, JSP and Wicket are two different worlds and the mindset of one doesn't work very well in the other.

How to add a template in to Symphony projects

I am new in Symphony and would like to add a new design. Here I have attached the file which I want to integrate in the user side. How is this possible?!
You'll need to use templates. Make sure you read through that page.
Chapter 2 of the Say Hello to Symphony tutorial deals with templates, and is a nice way of getting to grips with how it works.
Hopefully this will give the basic idea of how to control the HTML output using XSLT. You will then need to create your CSS to style your HTML.

Forms / structured data feature in Plone 4

We are trying to make a document-managemnet / knowledge management portal using Plone 4. We would like a forms / structured data feature in our webapp with posibility of defining forms through the web, having workflows using these forms and being able to create reports from them (preferably in some format that facilitates simple and nice looking or skinnable printouts).
Any pointers to modules, documentation and/or literature would be great. Thanks.
Dexterity in combination with collections for reporting should get you what you need.
http://plone.org/products/dexterity
PloneFormGen is a good solution for through the web creation of standalone forms but as soon as you need your form to be workflowed, reviewed inside plone or later edited and updated then a "Content Type" is normally the most appropriate way to model this inside an CMS. Dexterity is the recommended way to build content types going forward. It has the ability to create and edit content types through the web.
For more indepth information of developing a Dexterity based solution see http://plone.org/products/dexterity/documentation/manual/developer-manual
Archetypes would be an alternative way to create content types.
Collections can be used for basic through the web reports. To make this work on the new fields in your content types you'd need to make the fields usable inside collections which I'll leave out of this explanation. For more advanced reports I'd suggest a simple BrowserView which lets you use any python you want to compose your report.
The add-on http://plone.org/products/uwosh.pfg.d2c product with PloneFormGen, is going to be the best fit for your situation.
uwosh.pfg.d2c creates content objects from your PloneFormGen form submissions. You can then use it with placeful workflows to give you a custom workflow on the submission.
If you'd rather not use placeful workflows, it also allows you to specify the content type it'll save the form to so you can have a different content type, with a different workflow on every form.
Dexterity would work too, but the TTW tool is not nearly where PloneFormGen is.
Simply: http://plone.org/products/ploneformgen