var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
/* Generated from Java with JSweet 2.3.7 - http://www.jsweet.org */
import { JsonCompat } from '../../../compat/JsonCompat';
import { Constants } from '../../../core/Constants';
import { OasDataModelWriter } from '../../io/OasDataModelWriter';
/**
 * @author eric.wittmann@gmail.com
 * @class
 * @extends OasDataModelWriter
 */
var Oas30DataModelWriter = /** @class */ (function (_super) {
    __extends(Oas30DataModelWriter, _super);
    function Oas30DataModelWriter() {
        return _super.call(this) || this;
    }
    /**
     * @see io.apicurio.datamodels.core.io.DataModelWriter#writeDocument(io.apicurio.datamodels.core.models.Document, java.lang.Object)
     * @param {Document} node
     * @param {*} json
     */
    Oas30DataModelWriter.prototype.writeDocument = function (node, json) {
        var doc = node;
        JsonCompat.setPropertyString(json, Constants.PROP_OPENAPI, doc.openapi);
        JsonCompat.setPropertyNull(json, Constants.PROP_INFO);
        JsonCompat.setPropertyNull(json, Constants.PROP_SERVERS);
        JsonCompat.setPropertyNull(json, Constants.PROP_PATHS);
        JsonCompat.setPropertyNull(json, Constants.PROP_COMPONENTS);
        JsonCompat.setPropertyNull(json, Constants.PROP_SECURITY);
        JsonCompat.setPropertyNull(json, Constants.PROP_TAGS);
        JsonCompat.setPropertyNull(json, Constants.PROP_EXTERNAL_DOCS);
        this.writeExtraProperties(json, node);
    };
    /**
     * @see io.apicurio.datamodels.openapi.io.OasDataModelWriter#writeHeader(java.lang.Object, io.apicurio.datamodels.openapi.models.OasHeader)
     * @param {*} json
     * @param {OasHeader} node
     */
    Oas30DataModelWriter.prototype.writeHeader = function (json, node) {
        var header = node;
        JsonCompat.setPropertyString(json, Constants.PROP_$REF, header.$ref);
        JsonCompat.setPropertyBoolean(json, Constants.PROP_REQUIRED, header.required);
        JsonCompat.setPropertyBoolean(json, Constants.PROP_DEPRECATED, header.deprecated);
        JsonCompat.setPropertyBoolean(json, Constants.PROP_ALLOW_EMPTY_VALUE, header.allowEmptyValue);
        JsonCompat.setPropertyString(json, Constants.PROP_STYLE, header.style);
        JsonCompat.setPropertyBoolean(json, Constants.PROP_EXPLODE, header.explode);
        JsonCompat.setPropertyBoolean(json, Constants.PROP_ALLOW_RESERVED, header.allowReserved);
        JsonCompat.setPropertyNull(json, Constants.PROP_SCHEMA);
        JsonCompat.setProperty(json, Constants.PROP_EXAMPLE, header.example);
        JsonCompat.setPropertyNull(json, Constants.PROP_EXAMPLES);
        JsonCompat.setPropertyNull(json, Constants.PROP_CONTENT);
        _super.prototype.writeHeader.call(this, json, node);
    };
    /**
     * @see io.apicurio.datamodels.openapi.io.OasDataModelWriter#addHeaderToParent(java.lang.Object, java.lang.Object, io.apicurio.datamodels.openapi.models.OasHeader)
     * @param {*} parent
     * @param {*} json
     * @param {OasHeader} node
     */
    Oas30DataModelWriter.prototype.addHeaderToParent = function (parent, json, node) {
        var headers = JsonCompat.getProperty(parent, Constants.PROP_HEADERS);
        if (headers == null) {
            headers = JsonCompat.objectNode();
            JsonCompat.setProperty(parent, Constants.PROP_HEADERS, headers);
        }
        JsonCompat.setProperty(headers, node.getName(), json);
    };
    /**
     * @see io.apicurio.datamodels.openapi.io.OasDataModelWriter#writeOperation(java.lang.Object, io.apicurio.datamodels.core.models.common.Operation)
     * @param {*} json
     * @param {Operation} node
     */
    Oas30DataModelWriter.prototype.writeOperation = function (json, node) {
        JsonCompat.setPropertyNull(json, Constants.PROP_REQUEST_BODY);
        JsonCompat.setPropertyNull(json, Constants.PROP_CALLBACKS);
        JsonCompat.setPropertyNull(json, Constants.PROP_SERVERS);
        _super.prototype.writeOperation.call(this, json, node);
    };
    /**
     * @see io.apicurio.datamodels.openapi.io.OasDataModelWriter#writePathItem(java.lang.Object, io.apicurio.datamodels.openapi.models.OasPathItem)
     * @param {*} json
     * @param {OasPathItem} node
     */
    Oas30DataModelWriter.prototype.writePathItem = function (json, node) {
        var pathItem = node;
        JsonCompat.setPropertyString(json, Constants.PROP_SUMMARY, pathItem.summary);
        JsonCompat.setPropertyString(json, Constants.PROP_DESCRIPTION, pathItem.description);
        JsonCompat.setPropertyNull(json, Constants.PROP_TRACE);
        JsonCompat.setPropertyNull(json, Constants.PROP_SERVERS);
        _super.prototype.writePathItem.call(this, json, node);
    };
    /**
     * @see io.apicurio.datamodels.openapi.io.OasDataModelWriter#writeParameter(java.lang.Object, io.apicurio.datamodels.core.models.common.Parameter)
     * @param {*} json
     * @param {Parameter} node
     */
    Oas30DataModelWriter.prototype.writeParameter = function (json, node) {
        var parameter = node;
        JsonCompat.setPropertyBoolean(json, Constants.PROP_DEPRECATED, parameter.deprecated);
        JsonCompat.setPropertyString(json, Constants.PROP_STYLE, parameter.style);
        JsonCompat.setPropertyBoolean(json, Constants.PROP_EXPLODE, parameter.explode);
        JsonCompat.setPropertyBoolean(json, Constants.PROP_ALLOW_RESERVED, parameter.allowReserved);
        JsonCompat.setProperty(json, Constants.PROP_EXAMPLE, parameter.example);
        JsonCompat.setPropertyNull(json, Constants.PROP_EXAMPLES);
        JsonCompat.setPropertyNull(json, Constants.PROP_CONTENT);
        _super.prototype.writeParameter.call(this, json, node);
    };
    /**
     * @see io.apicurio.datamodels.openapi.io.OasDataModelWriter#writeResponse(java.lang.Object, io.apicurio.datamodels.openapi.models.OasResponse)
     * @param {*} json
     * @param {OasResponse} node
     */
    Oas30DataModelWriter.prototype.writeResponse = function (json, node) {
        var response = node;
        JsonCompat.setPropertyNull(json, Constants.PROP_HEADERS);
        JsonCompat.setPropertyNull(json, Constants.PROP_CONTENT);
        JsonCompat.setPropertyNull(json, Constants.PROP_LINKS);
        _super.prototype.writeResponse.call(this, json, response);
    };
    /**
     * @see io.apicurio.datamodels.openapi.io.OasDataModelWriter#writeSchema(java.lang.Object, io.apicurio.datamodels.core.models.common.Schema)
     * @param {*} json
     * @param {Schema} node
     */
    Oas30DataModelWriter.prototype.writeSchema = function (json, node) {
        var schema = node;
        JsonCompat.setPropertyNull(json, Constants.PROP_ONE_OF);
        JsonCompat.setPropertyNull(json, Constants.PROP_ANY_OF);
        JsonCompat.setPropertyNull(json, Constants.PROP_NOT);
        JsonCompat.setPropertyNull(json, Constants.PROP_DISCRIMINATOR);
        JsonCompat.setPropertyBoolean(json, Constants.PROP_NULLABLE, schema.nullable);
        JsonCompat.setPropertyBoolean(json, Constants.PROP_WRITE_ONLY, schema.writeOnly);
        JsonCompat.setPropertyBoolean(json, Constants.PROP_DEPRECATED, schema.deprecated);
        _super.prototype.writeSchema.call(this, json, node);
    };
    /**
     * @see io.apicurio.datamodels.core.io.DataModelWriter#writeSecurityScheme(java.lang.Object, io.apicurio.datamodels.core.models.common.SecurityScheme)
     * @param {*} json
     * @param {SecurityScheme} node
     */
    Oas30DataModelWriter.prototype.writeSecurityScheme = function (json, node) {
        var schema = node;
        JsonCompat.setPropertyString(json, Constants.PROP_$REF, schema.$ref);
        JsonCompat.setPropertyString(json, Constants.PROP_SCHEME, schema.scheme);
        JsonCompat.setPropertyString(json, Constants.PROP_BEARER_FORMAT, schema.bearerFormat);
        JsonCompat.setPropertyNull(json, Constants.PROP_FLOWS);
        JsonCompat.setPropertyString(json, Constants.PROP_OPEN_ID_CONNECT_URL, schema.openIdConnectUrl);
        _super.prototype.writeSecurityScheme.call(this, json, node);
    };
    /**
     * @see io.apicurio.datamodels.core.io.DataModelWriter#addParameterDefinitionToParent(java.lang.Object, java.lang.Object, io.apicurio.datamodels.core.models.common.IDefinition)
     * @param {*} parent
     * @param {*} json
     * @param {*} node
     */
    Oas30DataModelWriter.prototype.addParameterDefinitionToParent = function (parent, json, node) {
        var parameters = JsonCompat.getProperty(parent, Constants.PROP_PARAMETERS);
        if (parameters == null) {
            parameters = JsonCompat.objectNode();
            JsonCompat.setProperty(parent, Constants.PROP_PARAMETERS, parameters);
        }
        JsonCompat.setProperty(parameters, node.getName(), json);
    };
    /**
     * @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitComponents(io.apicurio.datamodels.core.models.common.Components)
     * @param {Components} node
     */
    Oas30DataModelWriter.prototype.visitComponents = function (node) {
        var parent = this.lookupParentJson$io_apicurio_datamodels_core_models_Node(node);
        var json = JsonCompat.objectNode();
        this.writeExtraProperties(json, node);
        JsonCompat.setProperty(parent, Constants.PROP_COMPONENTS, json);
        this.updateIndex(node, json);
    };
    /**
     * @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitCallbackPathItem(io.apicurio.datamodels.openapi.v3.models.Oas30CallbackPathItem)
     * @param {Oas30CallbackPathItem} node
     */
    Oas30DataModelWriter.prototype.visitCallbackPathItem = function (node) {
        this.visitPathItem(node);
    };
    /**
     * @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitCallback(io.apicurio.datamodels.openapi.v3.models.Oas30Callback)
     * @param {Oas30Callback} node
     */
    Oas30DataModelWriter.prototype.visitCallback = function (node) {
        var parent = this.lookupParentJson$io_apicurio_datamodels_core_models_Node(node);
        var json = JsonCompat.objectNode();
        this.writeCallback(json, node);
        this.writeExtraProperties(json, node);
        var callbacks = JsonCompat.getProperty(parent, Constants.PROP_CALLBACKS);
        if (callbacks == null) {
            callbacks = JsonCompat.objectNode();
            JsonCompat.setProperty(parent, Constants.PROP_CALLBACKS, callbacks);
        }
        JsonCompat.setProperty(callbacks, node.getName(), json);
        this.updateIndex(node, json);
    };
    Oas30DataModelWriter.prototype.writeCallback = function (json, node) {
        JsonCompat.setPropertyString(json, Constants.PROP_$REF, node.$ref);
    };
    /**
     * @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitLinkServer(io.apicurio.datamodels.openapi.v3.models.Oas30LinkServer)
     * @param {Oas30LinkServer} node
     */
    Oas30DataModelWriter.prototype.visitLinkServer = function (node) {
        var parent = this.lookupParentJson$io_apicurio_datamodels_core_models_Node(node);
        var json = JsonCompat.objectNode();
        JsonCompat.setPropertyString(json, Constants.PROP_URL, node.url);
        JsonCompat.setPropertyString(json, Constants.PROP_DESCRIPTION, node.description);
        JsonCompat.setPropertyNull(json, Constants.PROP_VARIABLES);
        this.writeExtraProperties(json, node);
        JsonCompat.setProperty(parent, Constants.PROP_SERVER, json);
        this.updateIndex(node, json);
    };
    /**
     * @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitCallbackDefinition(io.apicurio.datamodels.openapi.v3.models.Oas30CallbackDefinition)
     * @param {Oas30CallbackDefinition} node
     */
    Oas30DataModelWriter.prototype.visitCallbackDefinition = function (node) {
        this.visitCallback(node);
    };
    /**
     * @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitLink(io.apicurio.datamodels.openapi.v3.models.Oas30Link)
     * @param {Oas30Link} node
     */
    Oas30DataModelWriter.prototype.visitLink = function (node) {
        var parent = this.lookupParentJson$io_apicurio_datamodels_core_models_Node(node);
        var json = JsonCompat.objectNode();
        JsonCompat.setPropertyString(json, Constants.PROP_$REF, node.$ref);
        JsonCompat.setPropertyString(json, Constants.PROP_OPERATION_REF, node.operationRef);
        JsonCompat.setPropertyString(json, Constants.PROP_OPERATION_ID, node.operationId);
        JsonCompat.setPropertyNull(json, Constants.PROP_PARAMETERS);
        JsonCompat.setPropertyNull(json, Constants.PROP_REQUEST_BODY);
        JsonCompat.setPropertyString(json, Constants.PROP_DESCRIPTION, node.description);
        JsonCompat.setPropertyNull(json, Constants.PROP_SERVER);
        this.writeExtraProperties(json, node);
        var links = JsonCompat.getProperty(parent, Constants.PROP_LINKS);
        if (links == null) {
            links = JsonCompat.objectNode();
            JsonCompat.setProperty(parent, Constants.PROP_LINKS, links);
        }
        JsonCompat.setProperty(links, node.getName(), json);
        this.updateIndex(node, json);
    };
    /**
     * @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitLinkRequestBodyExpression(io.apicurio.datamodels.openapi.v3.models.Oas30LinkRequestBodyExpression)
     * @param {Oas30LinkRequestBodyExpression} node
     */
    Oas30DataModelWriter.prototype.visitLinkRequestBodyExpression = function (node) {
        var parent = this.lookupParentJson$io_apicurio_datamodels_core_models_Node(node);
        JsonCompat.setPropertyString(parent, Constants.PROP_REQUEST_BODY, node.getValue());
    };
    /**
     * @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitLinkParameterExpression(io.apicurio.datamodels.openapi.v3.models.Oas30LinkParameterExpression)
     * @param {Oas30LinkParameterExpression} node
     */
    Oas30DataModelWriter.prototype.visitLinkParameterExpression = function (node) {
        var parent = this.lookupParentJson$io_apicurio_datamodels_core_models_Node(node);
        var parameters = JsonCompat.getProperty(parent, Constants.PROP_PARAMETERS);
        if (parameters == null) {
            parameters = JsonCompat.objectNode();
            JsonCompat.setProperty(parent, Constants.PROP_PARAMETERS, parameters);
        }
        JsonCompat.setPropertyString(parameters, node.getName(), node.getValue());
    };
    /**
     * @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitLinkDefinition(io.apicurio.datamodels.openapi.v3.models.Oas30LinkDefinition)
     * @param {Oas30LinkDefinition} node
     */
    Oas30DataModelWriter.prototype.visitLinkDefinition = function (node) {
        this.visitLink(node);
    };
    /**
     * @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitAuthorizationCodeOAuthFlow(io.apicurio.datamodels.core.models.common.AuthorizationCodeOAuthFlow)
     * @param {AuthorizationCodeOAuthFlow} node
     */
    Oas30DataModelWriter.prototype.visitAuthorizationCodeOAuthFlow = function (node) {
        this.doVisitOAuthFlow(node, Constants.PROP_AUTHORIZATION_CODE);
    };
    /**
     * @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitClientCredentialsOAuthFlow(io.apicurio.datamodels.core.models.common.ClientCredentialsOAuthFlow)
     * @param {ClientCredentialsOAuthFlow} node
     */
    Oas30DataModelWriter.prototype.visitClientCredentialsOAuthFlow = function (node) {
        this.doVisitOAuthFlow(node, Constants.PROP_CLIENT_CREDENTIALS);
    };
    /**
     * @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitPasswordOAuthFlow(io.apicurio.datamodels.core.models.common.PasswordOAuthFlow)
     * @param {PasswordOAuthFlow} node
     */
    Oas30DataModelWriter.prototype.visitPasswordOAuthFlow = function (node) {
        this.doVisitOAuthFlow(node, Constants.PROP_PASSWORD);
    };
    /**
     * @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitImplicitOAuthFlow(io.apicurio.datamodels.core.models.common.ImplicitOAuthFlow)
     * @param {ImplicitOAuthFlow} node
     */
    Oas30DataModelWriter.prototype.visitImplicitOAuthFlow = function (node) {
        this.doVisitOAuthFlow(node, Constants.PROP_IMPLICIT);
    };
    /**
     * Visit an OAuth flow.
     * @param {OAuthFlow} node
     * @param {string} flowName
     */
    Oas30DataModelWriter.prototype.doVisitOAuthFlow = function (node, flowName) {
        var parent = this.lookupParentJson$io_apicurio_datamodels_core_models_Node(node);
        var json = JsonCompat.objectNode();
        JsonCompat.setPropertyString(json, Constants.PROP_AUTHORIZATION_URL, node.authorizationUrl);
        JsonCompat.setPropertyString(json, Constants.PROP_TOKEN_URL, node.tokenUrl);
        JsonCompat.setPropertyString(json, Constants.PROP_REFRESH_URL, node.refreshUrl);
        JsonCompat.setProperty(json, Constants.PROP_SCOPES, node.scopes);
        this.writeExtraProperties(json, node);
        JsonCompat.setProperty(parent, flowName, json);
        this.updateIndex(node, json);
    };
    /**
     * @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitOAuthFlows(io.apicurio.datamodels.core.models.common.OAuthFlows)
     * @param {OAuthFlows} node
     */
    Oas30DataModelWriter.prototype.visitOAuthFlows = function (node) {
        var parent = this.lookupParentJson$io_apicurio_datamodels_core_models_Node(node);
        var json = JsonCompat.objectNode();
        JsonCompat.setPropertyNull(json, Constants.PROP_IMPLICIT);
        JsonCompat.setPropertyNull(json, Constants.PROP_PASSWORD);
        JsonCompat.setPropertyNull(json, Constants.PROP_CLIENT_CREDENTIALS);
        JsonCompat.setPropertyNull(json, Constants.PROP_AUTHORIZATION_CODE);
        this.writeExtraProperties(json, node);
        JsonCompat.setProperty(parent, Constants.PROP_FLOWS, json);
        this.updateIndex(node, json);
    };
    /**
     * @see io.apicurio.datamodels.openapi.visitors.IOasVisitor#visitExample(io.apicurio.datamodels.core.models.common.IExample)
     * @param {*} node
     */
    Oas30DataModelWriter.prototype.visitExample = function (node) {
        var example30 = node;
        var parent = this.lookupParentJson$io_apicurio_datamodels_core_models_Node(example30);
        var json = JsonCompat.objectNode();
        JsonCompat.setPropertyString(json, Constants.PROP_$REF, example30.$ref);
        JsonCompat.setPropertyString(json, Constants.PROP_SUMMARY, example30.summary);
        JsonCompat.setPropertyString(json, Constants.PROP_DESCRIPTION, example30.description);
        JsonCompat.setProperty(json, Constants.PROP_VALUE, example30.value);
        JsonCompat.setPropertyString(json, Constants.PROP_EXTERNAL_VALUE, example30.externalValue);
        this.writeExtraProperties(json, example30);
        var examples = JsonCompat.getProperty(parent, Constants.PROP_EXAMPLES);
        if (examples == null) {
            examples = JsonCompat.objectNode();
            JsonCompat.setProperty(parent, Constants.PROP_EXAMPLES, examples);
        }
        JsonCompat.setProperty(examples, example30.getName(), json);
        this.updateIndex(example30, json);
    };
    /**
     * @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitEncoding(io.apicurio.datamodels.openapi.v3.models.Oas30Encoding)
     * @param {Oas30Encoding} node
     */
    Oas30DataModelWriter.prototype.visitEncoding = function (node) {
        var parent = this.lookupParentJson$io_apicurio_datamodels_core_models_Node(node);
        var json = JsonCompat.objectNode();
        JsonCompat.setPropertyString(json, Constants.PROP_CONTENT_TYPE, node.contentType);
        JsonCompat.setPropertyNull(json, Constants.PROP_HEADERS);
        JsonCompat.setPropertyString(json, Constants.PROP_STYLE, node.style);
        JsonCompat.setPropertyBoolean(json, Constants.PROP_EXPLODE, node.explode);
        JsonCompat.setPropertyBoolean(json, Constants.PROP_ALLOW_RESERVED, node.allowReserved);
        this.writeExtraProperties(json, node);
        var encoding = JsonCompat.getProperty(parent, Constants.PROP_ENCODING);
        if (encoding == null) {
            encoding = JsonCompat.objectNode();
            JsonCompat.setProperty(parent, Constants.PROP_ENCODING, encoding);
        }
        JsonCompat.setProperty(encoding, node.getName(), json);
        this.updateIndex(node, json);
    };
    /**
     * @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitMediaType(io.apicurio.datamodels.openapi.v3.models.Oas30MediaType)
     * @param {Oas30MediaType} node
     */
    Oas30DataModelWriter.prototype.visitMediaType = function (node) {
        var parent = this.lookupParentJson$io_apicurio_datamodels_core_models_Node(node);
        var json = JsonCompat.objectNode();
        JsonCompat.setPropertyNull(json, Constants.PROP_SCHEMA);
        JsonCompat.setProperty(json, Constants.PROP_EXAMPLE, node.example);
        JsonCompat.setPropertyNull(json, Constants.PROP_EXAMPLES);
        JsonCompat.setPropertyNull(json, Constants.PROP_ENCODING);
        this.writeExtraProperties(json, node);
        var content = JsonCompat.getProperty(parent, Constants.PROP_CONTENT);
        if (content == null) {
            content = JsonCompat.objectNode();
            JsonCompat.setProperty(parent, Constants.PROP_CONTENT, content);
        }
        JsonCompat.setProperty(content, node.getName(), json);
        this.updateIndex(node, json);
    };
    /**
     * @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitHeaderDefinition(io.apicurio.datamodels.openapi.v3.models.Oas30HeaderDefinition)
     * @param {Oas30HeaderDefinition} node
     */
    Oas30DataModelWriter.prototype.visitHeaderDefinition = function (node) {
        var parent = this.lookupParentJson$io_apicurio_datamodels_core_models_Node(node);
        var json = JsonCompat.objectNode();
        this.writeHeader(json, node);
        this.writeExtraProperties(json, node);
        var headers = JsonCompat.getProperty(parent, Constants.PROP_HEADERS);
        if (headers == null) {
            headers = JsonCompat.objectNode();
            JsonCompat.setProperty(parent, Constants.PROP_HEADERS, headers);
        }
        JsonCompat.setProperty(headers, node.getName(), json);
        this.updateIndex(node, json);
    };
    /**
     * @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitRequestBody(io.apicurio.datamodels.openapi.v3.models.Oas30RequestBody)
     * @param {Oas30RequestBody} node
     */
    Oas30DataModelWriter.prototype.visitRequestBody = function (node) {
        var parent = this.lookupParentJson$io_apicurio_datamodels_core_models_Node(node);
        var json = JsonCompat.objectNode();
        this.writeRequestBody(json, node);
        this.writeExtraProperties(json, node);
        JsonCompat.setProperty(parent, Constants.PROP_REQUEST_BODY, json);
        this.updateIndex(node, json);
    };
    /**
     * @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitRequestBodyDefinition(io.apicurio.datamodels.openapi.v3.models.Oas30RequestBodyDefinition)
     * @param {Oas30RequestBodyDefinition} node
     */
    Oas30DataModelWriter.prototype.visitRequestBodyDefinition = function (node) {
        var parent = this.lookupParentJson$io_apicurio_datamodels_core_models_Node(node);
        var json = JsonCompat.objectNode();
        this.writeRequestBody(json, node);
        this.writeExtraProperties(json, node);
        var requestBodies = JsonCompat.getProperty(parent, Constants.PROP_REQUEST_BODIES);
        if (requestBodies == null) {
            requestBodies = JsonCompat.objectNode();
            JsonCompat.setProperty(parent, Constants.PROP_REQUEST_BODIES, requestBodies);
        }
        JsonCompat.setProperty(requestBodies, node.getName(), json);
        this.updateIndex(node, json);
    };
    Oas30DataModelWriter.prototype.writeRequestBody = function (json, node) {
        JsonCompat.setPropertyString(json, Constants.PROP_$REF, node.$ref);
        JsonCompat.setPropertyString(json, Constants.PROP_DESCRIPTION, node.description);
        JsonCompat.setPropertyNull(json, Constants.PROP_CONTENT);
        JsonCompat.setPropertyBoolean(json, Constants.PROP_REQUIRED, node.required);
    };
    /**
     * @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitExampleDefinition(io.apicurio.datamodels.openapi.v3.models.Oas30ExampleDefinition)
     * @param {Oas30ExampleDefinition} node
     */
    Oas30DataModelWriter.prototype.visitExampleDefinition = function (node) {
        this.visitExample(node);
    };
    /**
     * @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitDiscriminator(io.apicurio.datamodels.openapi.v3.models.Oas30Discriminator)
     * @param {Oas30Discriminator} node
     */
    Oas30DataModelWriter.prototype.visitDiscriminator = function (node) {
        var parent = this.lookupParentJson$io_apicurio_datamodels_core_models_Node(node);
        var json = JsonCompat.objectNode();
        JsonCompat.setPropertyString(json, Constants.PROP_PROPERTY_NAME, node.propertyName);
        JsonCompat.setProperty(json, Constants.PROP_MAPPING, node.mapping);
        this.writeExtraProperties(json, node);
        JsonCompat.setProperty(parent, Constants.PROP_DISCRIMINATOR, json);
        this.updateIndex(node, json);
    };
    /**
     * @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitNotSchema(io.apicurio.datamodels.openapi.v3.models.Oas30Schema.Oas30NotSchema)
     * @param {Oas30Schema.Oas30NotSchema} node
     */
    Oas30DataModelWriter.prototype.visitNotSchema = function (node) {
        this.doVisitSchema(node, Constants.PROP_NOT, false);
    };
    /**
     * @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitOneOfSchema(io.apicurio.datamodels.openapi.v3.models.Oas30Schema.Oas30OneOfSchema)
     * @param {Oas30Schema.Oas30OneOfSchema} node
     */
    Oas30DataModelWriter.prototype.visitOneOfSchema = function (node) {
        this.doVisitSchema(node, Constants.PROP_ONE_OF, true);
    };
    /**
     * @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitAnyOfSchema(io.apicurio.datamodels.openapi.v3.models.Oas30Schema.Oas30AnyOfSchema)
     * @param {Oas30Schema.Oas30AnyOfSchema} node
     */
    Oas30DataModelWriter.prototype.visitAnyOfSchema = function (node) {
        this.doVisitSchema(node, Constants.PROP_ANY_OF, true);
    };
    /**
     * @see io.apicurio.datamodels.core.io.DataModelWriter#addSchemaDefinitionToParent(java.lang.Object, java.lang.Object, io.apicurio.datamodels.core.models.common.IDefinition)
     * @param {*} parent
     * @param {*} json
     * @param {*} node
     */
    Oas30DataModelWriter.prototype.addSchemaDefinitionToParent = function (parent, json, node) {
        var schemas = JsonCompat.getProperty(parent, Constants.PROP_SCHEMAS);
        if (schemas == null) {
            schemas = JsonCompat.objectNode();
            JsonCompat.setProperty(parent, Constants.PROP_SCHEMAS, schemas);
        }
        JsonCompat.setProperty(schemas, node.getName(), json);
    };
    /**
     * @see io.apicurio.datamodels.openapi.io.OasDataModelWriter#addResponseDefinitionToParent(java.lang.Object, java.lang.Object, io.apicurio.datamodels.core.models.common.IDefinition)
     * @param {*} parent
     * @param {*} json
     * @param {*} node
     */
    Oas30DataModelWriter.prototype.addResponseDefinitionToParent = function (parent, json, node) {
        var responses = JsonCompat.getProperty(parent, Constants.PROP_RESPONSES);
        if (responses == null) {
            responses = JsonCompat.objectNode();
            JsonCompat.setProperty(parent, Constants.PROP_RESPONSES, responses);
        }
        JsonCompat.setProperty(responses, node.getName(), json);
    };
    /**
     * @see io.apicurio.datamodels.core.io.DataModelWriter#addSecuritySchemeToParent(java.lang.Object, java.lang.Object, io.apicurio.datamodels.core.models.common.SecurityScheme)
     * @param {*} parent
     * @param {*} json
     * @param {SecurityScheme} node
     */
    Oas30DataModelWriter.prototype.addSecuritySchemeToParent = function (parent, json, node) {
        var securitySchemes = JsonCompat.getProperty(parent, Constants.PROP_SECURITY_SCHEMES);
        if (securitySchemes == null) {
            securitySchemes = JsonCompat.objectNode();
            JsonCompat.setProperty(parent, Constants.PROP_SECURITY_SCHEMES, securitySchemes);
        }
        JsonCompat.setProperty(securitySchemes, node.getSchemeName(), json);
    };
    /**
     * @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitServer(io.apicurio.datamodels.core.models.common.Server)
     * @param {Server} node
     */
    Oas30DataModelWriter.prototype.visitServer = function (node) {
        var parent = this.lookupParentJson$io_apicurio_datamodels_core_models_Node(node);
        var json = JsonCompat.objectNode();
        this.writeServer(json, node);
        this.writeExtraProperties(json, node);
        JsonCompat.appendToArrayProperty(parent, Constants.PROP_SERVERS, json);
        this.updateIndex(node, json);
    };
    Oas30DataModelWriter.prototype.writeServer = function (json, node) {
        JsonCompat.setPropertyString(json, Constants.PROP_URL, node.url);
        JsonCompat.setPropertyString(json, Constants.PROP_DESCRIPTION, node.description);
        JsonCompat.setPropertyNull(json, Constants.PROP_VARIABLES);
    };
    /**
     * @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitServerVariable(io.apicurio.datamodels.core.models.common.ServerVariable)
     * @param {ServerVariable} node
     */
    Oas30DataModelWriter.prototype.visitServerVariable = function (node) {
        var parent = this.lookupParentJson$io_apicurio_datamodels_core_models_Node(node);
        var json = JsonCompat.objectNode();
        this.writeServerVariable(json, node);
        this.writeExtraProperties(json, node);
        var variables = JsonCompat.getProperty(parent, Constants.PROP_VARIABLES);
        if (variables == null) {
            variables = JsonCompat.objectNode();
            JsonCompat.setProperty(parent, Constants.PROP_VARIABLES, variables);
        }
        JsonCompat.setProperty(variables, node.getName(), json);
        this.updateIndex(node, json);
    };
    Oas30DataModelWriter.prototype.writeServerVariable = function (json, node) {
        JsonCompat.setPropertyStringArray(json, Constants.PROP_ENUM, node.enum_);
        JsonCompat.setPropertyString(json, Constants.PROP_DEFAULT, node.default_);
        JsonCompat.setPropertyString(json, Constants.PROP_DESCRIPTION, node.description);
        JsonCompat.setPropertyNull(json, Constants.PROP_VARIABLES);
    };
    return Oas30DataModelWriter;
}(OasDataModelWriter));
export { Oas30DataModelWriter };
Oas30DataModelWriter["__class"] = "io.apicurio.datamodels.openapi.v3.io.Oas30DataModelWriter";
Oas30DataModelWriter["__interfaces"] = ["io.apicurio.datamodels.core.visitors.IVisitor", "io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor", "io.apicurio.datamodels.openapi.visitors.IOasVisitor"];
//# sourceMappingURL=Oas30DataModelWriter.js.map