src/store/modules/schemas.js
/**
   * Check the compatibility with the given schema and the latest
   * schema version. A Error is thrown if the schema is incompatible
   * @param  {String} options.subject Subject name
   * @param  {Object} options.schema  Schema to be validated
   */
Check the compatibility with the given schema and the latest
schema version. A Error is thrown if the schema is incompatible
@param  {String} options.subject Subject name
@param  {Object} options.schema  Schema to be validated
Check the compatibility with the given schema and the latest schema version . A Error is thrown if the schema is incompatible @param { String } options . subject Subject name @param { Object } options . schema Schema to be validated
async checkCompatibilityLatest ({state}, {subject, schema}) {
    const info = state.subjects[subject]
    schema = JSON.stringify(schema)
    if (!info) {
      throw new Error(`the subject: ${subject} was not found in the store`)
    }
    const versions = Object.keys(info)
    if (versions.length <= 0) {
      throw new Error(`no versions are found for the given subject: ${subject}`)
    }
    const latest = Math.max(...versions)
    const latestSchema = info[latest].schema
    if (JSON.stringify(latestSchema) === schema) {
      throw new Error('the schema has not been changed')
    }
    const {data} = await clusters.request(CLUSTER_SCHEMA_REGISTRY, {
      accept: SCHEMA_CONTENT_JSON
    }).post(`/compatibility/subjects/${subject}/versions/${latest}`, {
      schema
    })
    if (!data.is_compatible) {
      throw new Error('the given schema is incompatible with the latest version')
    }
  }
async checkCompatibilityLatest ( { state } , { subject , schema } ) { const info = state . subjects [ subject ] schema = JSON . stringify ( schema ) if ( ! info ) { throw new Error ( ` ${ subject } ` ) } const versions = Object . keys ( info ) if ( versions . length <= 0 ) { throw new Error ( ` ${ subject } ` ) } const latest = Math . max ( ... versions ) const latestSchema = info [ latest ] . schema if ( JSON . stringify ( latestSchema ) === schema ) { throw new Error ( 'the schema has not been changed' ) } const { data } = await clusters . request ( CLUSTER_SCHEMA_REGISTRY , { accept : SCHEMA_CONTENT_JSON } ) . post ( ` ${ subject } ${ latest } ` , { schema } ) if ( ! data . is_compatible ) { throw new Error ( 'the given schema is incompatible with the latest version' ) } }
Check the compatibility with the given schema and the latest
 schema version.
Check the compatibility with the given schema and the latest schema version .