How to customize the swagger-editor to include other definitions besides the PetStore
Hello all,
I'm trying to customize some of the defaults of Swagger-editor (https://swagger.io/tools/swagger-editor/) and I wonder if you can help.
What I have and found so far
Basically I do have a collection of generated Swagger/ OpenAPI compatible schemas on JSON format and I want to show them on the default menus of the editor:
Ideally I would also love to load my own definition instead of the default PetStore definition.
So far I found the following:
src/standalone/topbar/components/Topbar.jsx has a method to preload Petstore definitions:
import { petStoreOas2Def, petStoreOas3Def } from "../../../plugins/default-definitions"
// Further down
loadPetStoreOas2 = () => {
this.props.specActions.updateSpec(petStoreOas2Def)
}
loadPetStoreOas3 = () => {
this.props.specActions.updateSpec(petStoreOas3Def)
}Looks promising, I guess I could add my own definitions there. The definitions are not on this file but src/plugins/default-definitions/index.js
export const petStoreOas3Def = `openapi: 3.0.4
info:
title: Swagger Petstore - OpenAPI 3.0
description: |-
This is a sample Pet Store Server based on the OpenAPI 3.0 specification. You can find out more about
Swagger at [https://swagger.io](https://swagger.io). In the third iteration of the pet store, we've switched to the design first approach!
You can now help us improve the API whether it's by making changes to the definition itself or to the code.
That way, with time, we can improve the API in general, and expose some of the new features in OAS3.Each definition seems to start with a "export const petStoreOas3Def = `openapi: 3.0.4", followed by the YAML definition.
Questions below:
- What is the right way to add custom definitions? I'm very new to Node JS and I do have ability to recompile the application but I'm not sure if I'm going through the Rabbit hole here.
- There is a way to navigate the swagger-editor self hosted page, with a GET parameter (like swaggerdef=http://someotherdef.json, so the editor displays it to the user immediately?
Thanks in advance,
--Jose