Hi,
I currently have the editor object[1] with me and also a Swagger YAML value as a string with me. How set the swagger YAML value to the editor ?
Where can I find the API documentation of the SwaggerEditorBundle object ?
[1] - https://github.com/swagger-api/swagger-editor/blob/master/index.html#L50
Regards,
Hemika
Ping!
You want to set the default YAML loaded with the editor (something different than the pet store)?
@webron Yes. And also need a way to get the YAML content from the editor ? Need a way to set the Swagger content without using a url.
Is there a way to access the ace editor events ? Need an onChange like event when a YAML content is changed with location(line number).
Can we access the ace editor object as well ?
Can you explain your use case? I don't understand what you're trying to do.
I have embedded the swagger editor to my web application.
I have a swagger YAML content as a variable which I need to set as the content of the swagger editor. Similarly, when the editor's YAML content is changed, i'll like to get the new YAML content.
I also have a need to event which is triggered when the Swagger editor content is changed.
I have created the swagger editor as follows :
self._swaggerEditor = SwaggerEditorBundle({
dom_id: '#' + 'z-' + self._options.swaggerEditorId
});
I'd like to use the self._swaggerEditor object to set and get the Swagger YAML to the editor. Is this possible ?
@hemikak, you can get the editor's value dynamically by calling self._swaggerEditor.specSelectors.specStr(), and set the value by calling self._swaggerEditor.updateSpec('new string for the editor').
Cheers!
Thanks!
Just looked over this again- my apologies, the correct way to set the value is self._swaggerEditor.specActions.updateSpec('new string for the editor').
Other than that, you should be good to go. Thanks for using Swagger!
Thanks Shockey it worked for me.
Also: setting url:
const editor = SwaggerEditorBundle({
url: "/swagger.yaml", // To Remove PetStore and add my Own API
dom_id: '#swagger-editor',
layout: 'StandaloneLayout',
presets: [
SwaggerEditorStandalonePreset
]
})
Most helpful comment
Just looked over this again- my apologies, the correct way to set the value is
self._swaggerEditor.specActions.updateSpec('new string for the editor').Other than that, you should be good to go. Thanks for using Swagger!