swagger-editor icon indicating copy to clipboard operation
swagger-editor copied to clipboard

How to get a list of the current validation errors?

Open rdawson-hmrc opened this issue 5 months ago • 0 comments

I have embedded the Swagger Editor in a web page and need to be able to tell from my own JavaScript code whether the document currently in the editor has any validation errors. I've tried exploring the system object that is available within plugins, something like this

const SpecUpdateListenerPlugin = function(system) {
        return {
            statePlugins: {
                spec: {
                    wrapActions: {
                        updateSpec: (oriAction) => (...args) => {
                            const [str] = args
                            console.log("ERRORS", system.errSelectors.allErrors().toJS())
                            return oriAction(...args)
                        }
                    }
                }
            }
        }
    }

but this seems unreliable, is there a better way please?

rdawson-hmrc avatar Mar 05 '24 12:03 rdawson-hmrc