Extending swagger rules - swagger

I am new to openapi swagger. While exploring the yaml and the rules, I wish to enforce my own rules that swagger editor must follow. Like all get requests must start with MLGetDataModule_ . Some help in this regards will be highly appreciated.
I did read the extending the open api specification from Link but it talks about adding new properties and not adding new rules . Please guide .

Related

ASP.NET Core Web API : use custom OpenApi specification

I create an API and I would like to use my custom OpenAPI specification for Swagger. Because I go design first. I don't want to generate code from OpenAPI spec; I just want to pass it to Swagger. And I have many separated yml files.
Is it possible?
Thank you
I found it. I have bad set cors... Thanks

Swaggerhub integration in spring boot

I am new to swaggerhub so please explain me from basics.
In our project we are using springfox swagger and need to generate swaggerhub api specification.
How can I achieve this? Please let me know in detail or share reference links.
Your question is a little confusing. What do you mean by "swaggerhub api specification"?
Swagger is the documentation specification/tools used to work with the document spec. SwaggerHub is a design and collaboration tools for creating and maintaining Swagger documents.
SwaggerHub hosts Swagger documents, they work together rather than independently.
If you're creating Swagger documents and want to upload them to SwaggerHub automatically, you can do that using the SwaggerHub CLI or Registry API tools:
CLI: https://github.com/SmartBear/swaggerhub-cli
Registry API: https://app.swaggerhub.com/apis-docs/swagger-hub/registry-api/1.0.62

Springdoc OpenAPI UI Documentation

Is it possible to generate swagger ui documentation using interfaces rather than controller classes which implement the those interfaces?
Putting the documentation in the implementation class makes it look cluttered.
Springfox had this option, is it available in springdoc? If so, how to do it?
You just add the OpenAPI annotations on the interface level. An it just works.
This is a sample working demo and the annotation are on the interface level as well:
https://github.com/springdoc/springdoc-openapi-demos/tree/master/springdoc-openapi-spring-boot-2-webmvc

Export list of API Paths from OpenAPI spec using swagger ui

I have a bunch of APIs that are documented as OpenAPI v3 specs.
Eg: foo.yaml, bar.yaml and baz.yaml
I also have a Web server that displays the specs in the swagger ui, so all my swagger models are easily consumable by devs, designers and so on.
My question: is there an easy way, using the javascript console, to give me a list of the resource paths?
I've had a quick look around the swagger ui source code but couldn't find anything useful, other than the SwaggerUIBundle object.
The API definition is accessible via ui.specSelectors.specJson(). The value is an Immutable.js Map.
You can use the following code to list all the paths:
let paths = ui.specSelectors.specJson().get("paths")
paths.mapKeys(key => console.log(key))

Swagger annotations and Swagger spec 2.0

I've developed a REST API anotated with Swagger annotations.
I've been able to show the api documentation on a swagger-ui application, very nice.
The problem:
I'm trying to generate clients acording this specification using the url provided by swagger acording my anotations.
The porblem is it seems to be imcompatible, or at least, I don't see how to do the swagger editor reads my url and from then on, generate clients. But swagger editor reports me about some errors...
It's possible to integrate my anotated swagger api with a swagger editor?
Thanks.
The question seems a bit confusing.
If you are trying to generate clients from your REST API Swagger spec, then you should take a look to Swagger-Codegen project.
Description of project:
swagger-codegen contains a template-driven engine to generate client code in different languages by parsing your Swagger Resource Declaration.
Link to repository: https://github.com/swagger-api/swagger-codegen/
Link to official page: http://swagger.io/swagger-codegen/
Not sure if I understand the question correctly. If you want to generate API clients online, you an use http://generator.swagger.io (besides http://editor.swagger.io). Here is an example to generate API client for Java:
curl -X POST -H "content-type:application/json" -d '{"swaggerUrl":"http://petstore.swagger.io/v2/swagger.json"}' http://generator.swagger.io/api/gen/clients/java
Swagger editor is used only for editing a swagger spec in either json or yml format. It does not deal with swagger annotations in any way. However, some of the server skeletons that are generated on the swagger-editor website contain annotations. The annotations are a way of reverse engineering your API to generate a json file so that swagger UI can render a webpage based on the public url path to your swagger.json file.
If you are maintaining a swagger spec json file anyways, the annotations aren't really needed, you might as well just serve up the raw swagger.json itself, rather than the json that is generated by the annotations.
As to your question, "Is it possible to integrate your API with swagger editor?"... Anything is possible, but I'm not sure as to how or why you want to integrate them.

Resources