Пример #1
0
        public override void Patch(OpenApiSchema schema, OpenApiObject xProps, OpenApiObject templateOptions,
                                   LinkGenerator linkGenerator,
                                   List <ValidatorModel> validators)
        {
            base.Patch(schema, xProps, templateOptions, linkGenerator, validators);

            var customConfig = templateOptions.GetOrSetDefault <OpenApiObject, IOpenApiAny>("customFieldConfig");

            customConfig["labelProp"] = new OpenApiString(LabelProp);
            customConfig["valueProp"] = new OpenApiString(ValueProp);

            var optionsUrl = OptionsControllerType != null
                ? linkGenerator.GetAbsolutePathByAction(OptionsActionName,
                                                        TypeHelpers.GetControllerName(OptionsControllerType))
                : OptionsUrl;

            customConfig["loadOptionsFromUrl"] = new OpenApiBoolean(true);
            customConfig["optionsUrl"]         = new OpenApiString(optionsUrl);

            customConfig["reloadOptionsOnInit"] = new OpenApiBoolean(ReloadOptionsOnInit);
            customConfig["showReloadButton"]    = new OpenApiBoolean(ShowReloadButton);

            var fieldGroupFill = customConfig.GetOrSetDefault <OpenApiObject, IOpenApiAny>("fieldGroupFill");

            fieldGroupFill["enabled"]           = new OpenApiBoolean(true);
            fieldGroupFill["keepValueProp"]     = new OpenApiBoolean(KeepValueProp);
            fieldGroupFill["selectorFieldType"] = new OpenApiString(SelectorFieldType ?? "autocomplete");
        }