Swagger-editor: Add a backend for saving API specs

Created on 19 Sep 2014  Â·  24Comments  Â·  Source: swagger-api/swagger-editor

Is it possible to have a feature to save the api defintions directly into the YAML file instead of localstorage. It would be much more helpful for a team division for developing APIs.

backend (retired) enhancement

Most helpful comment

this issue is quite old, but it's the first one in google result, if you are a newbie like me, take a look at https://github.com/swagger-api/swagger-node it supports edit local swagger yaml file and mock server, even a real express server is also supported. maybe @mohsen1 you could add swagger-node to readme, it's a lot better than http-server

All 24 comments

You can download the YAML file to your disk but because it's a web app it can't manipulate that file on your disk. We are working on a backend that saves your YAML in a database and give you a unique link to it. That is coming soon

Now that we have a docker container for this image, I think there might be an easier approach. If a developer is running their own copy of swagger-editor locally the webapp can have access to the local files, you just have to configure the webapp to use a directory.

I think all that is required is:

  • new endpoint to save the file
  • new menu item to save
  • new config option for the directory to use

@dnephin Swagger Editor can use a backend for saving and loading yaml content. All you need to do is to configure defaults.js. Please look at apigee-127.js for an example

Cool, I'll check that out. Are these settings in the defaults.js documented anywhere? I haven't been able to find many docs about the editor. If they don't exist yet, how would you feel about some markdown in ./docs ?

Good feedback @dnephin . Would you mind either updating README or linking a page from README?

Yup, I'm still trying to figure a lot of this out myself. I can write down what I find, but it's certain to be incomplete.

I've figured it out myself. My requirement is pretty basic. Hence I didn't
even use a db. I directly am editing the files using a php server and a
json editor i found at http://www.jsoneditoronline.org/.

But it would be very good to have a service which has an integration with
github (for version controlling) and also the capability of multiple people
managing these at the same time.

On Tue, Oct 7, 2014 at 9:30 AM, Daniel Nephin [email protected]
wrote:

Yup, I'm still trying to figure a lot of this out myself. I can write down
what I find, but it's certain to be incomplete.

—
Reply to this email directly or view it on GitHub
https://github.com/wordnik/swagger-editor/issues/174#issuecomment-58133491
.

I worked on a backend to integrate that with the editor. It's here https://github.com/mohsen1/anybin

I might put the backend and editor together at some point but for now GitHub is a great idea. I will explore the idea of saving it to a GitHub Gist via their API. You get the versioning too which is great!

Any update on this ticket?

Swagger Editor can use a backend but it doesn't have a backed nor it is planned yet.

Thanks, Where can I find information on how to integrate Swagger Editor with GitHub repository for API specs?

Meaning, when I modify the yaml in the editor, i want to persist in GitHub once I am satisfied with my changes and share the link with my colleagues.

Thanks in advance!

@mohsen1 How can we use the backend? Is there configuration needed? Thanks

@mohsen1 Never mind, found some information under "Backends" section in the Configuration guide.

this issue is quite old, but it's the first one in google result, if you are a newbie like me, take a look at https://github.com/swagger-api/swagger-node it supports edit local swagger yaml file and mock server, even a real express server is also supported. maybe @mohsen1 you could add swagger-node to readme, it's a lot better than http-server

Hi having a back end is out of scope for this project. It's developed so you can add one, but it doesn't belong here in this project.

This is a bit disappointing, though I'm assuming its due to SwaggerHub. Incase anyone (I can name at least 10 people) still needs this feature, FWIW I created something similar by iFraming the editor within a management interface, and dynamically assigning the import parameter, and the back end endpoints, and doing all the tying up outside of the editor. Possibly (without looking in great detail) a bit how swagger hub works

It's not due to swagger hub, it's a separation of concerns for this product. Same reason why swagger-UI doesn't ship with a server either.

I had the same issue, wrote a small backend to solve it, feel free to try:
https://github.com/zgiber/sweb

I know this topic is closed and old, but i created a docker which contains a Swagger "IDE".
It includes the Swagger Editor with backend, Swagger UI and Swagger API Mock.
The Swagger UI always uses the current yaml of the editor.
The Swagger API Mock is reachable under port 8000 and stays also always synchronous with the current yaml of the editor.
Further information: https://hub.docker.com/r/20029119312185181/swagger-ide/

Thank you @cato1011 - can u share the source for this swagger-ide, if possible.

Cat01011, I tried your docker and it seems working fine. But I have a question: where does it store the yml with your changes in the docker Container? Basically I would like to find the yaml, and maybe have a script that can do git commit/push.

this issue is quite old, but it's the first one in google result, if you are a newbie like me, take a look at https://github.com/swagger-api/swagger-node it supports edit local swagger yaml file and mock server, even a real express server is also supported. maybe @mohsen1 you could add swagger-node to readme, it's a lot better than http-server

it seems that swagger-node is not really maintained. I installed it via npm but the editor there is pretty old. (2.10.15). I am using

docker run -d --rm --name swaggereditor -p 81:8080 swaggerapi/swagger-editor and would be glad if I could mount a volume with my swaggerfile.

What @bwl21 asked can be accomplished by mounting your swaggerfile/directory as a volume and passing a SWAGGER_FILE env-var pointing to it. Something like this:

docker run -v $(pwd)/path/to/openapi.yaml:/spec/openapi.yaml \
           -e SWAGGER_FILE=/spec/openapi.yaml \
           -p 8080:8080 \
           swaggerapi/swagger-editor

It works with both .yaml and .json files, although it is quite unreadable in JSON. It still requires you to manually download the changed file, though :(

I tried all of the suggestions above, in terms of Docker images. Some simply don't work, while others are outdated (old version of Swagger, for instance, which is also the case of an alternative that wasn't listed here, https://github.com/huan/swagger-edit). Too bad we haven't seen any progress on that...

Nonetheless, these alternatives (some free, some open source) might help anyone still looking for a satisfiable answer (other than running swagger-ui and hand-editing the openapi.yaml file): https://openapi.tools/#text-editors.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jennaprice picture jennaprice  Â·  4Comments

ljerka picture ljerka  Â·  5Comments

weldpua2008 picture weldpua2008  Â·  6Comments

variable picture variable  Â·  4Comments

freak4pc picture freak4pc  Â·  3Comments