Пример #1
0
        private static void AddConsoleLoggerOptionsSubSchema <TOptions>(GenerationContext context, ConsoleLoggerFormat consoleLoggerFormat)
        {
            JsonSchema consoleLoggerOptionsSchema = new JsonSchema();

            consoleLoggerOptionsSchema.RequiredProperties.Add(nameof(ConsoleLoggerOptions.FormatterName));

            JsonSchemaProperty formatterOptionsProperty = AddDiscriminatedSubSchema(
                context.Schema.Definitions[nameof(ConsoleLoggerOptions)],
                nameof(ConsoleLoggerOptions.FormatterName),
                consoleLoggerFormat.ToString(),
                nameof(ConsoleLoggerOptions.FormatterOptions),
                consoleLoggerOptionsSchema);

            formatterOptionsProperty.Reference = context.AddTypeIfNotExist <TOptions>();
        }
Пример #2
0
        private static void AddDefaultConsoleLoggerOptionsSubSchema(GenerationContext context)
        {
            JsonSchema consoleLoggerOptionsSchema = new JsonSchema();

            JsonSchemaProperty formatterNameProperty    = new JsonSchemaProperty();
            JsonSchemaProperty formatterOptionsProperty = new JsonSchemaProperty();

            formatterOptionsProperty.Reference = context.AddTypeIfNotExist <SimpleConsoleFormatterOptions>();

            formatterNameProperty.Type    = JsonObjectType.Null;
            formatterNameProperty.Default = "Simple";

            consoleLoggerOptionsSchema.Properties.Add(nameof(ConsoleLoggerOptions.FormatterName), formatterNameProperty);
            consoleLoggerOptionsSchema.Properties.Add(nameof(ConsoleLoggerOptions.FormatterOptions), formatterOptionsProperty);

            context.Schema.Definitions[nameof(ConsoleLoggerOptions)].OneOf.Add(consoleLoggerOptionsSchema);
        }
Пример #3
0
        private static void AddCollectionRuleTriggerSchema <TOptions>(GenerationContext context, JsonSchema triggerTypeSchema, string triggerType)
        {
            JsonSchema subSchema = new JsonSchema();

            subSchema.RequiredProperties.Add(nameof(CollectionRuleTriggerOptions.Settings));

            JsonSchemaProperty settingsProperty = AddDiscriminatedSubSchema(
                context.Schema.Definitions[nameof(CollectionRuleTriggerOptions)],
                nameof(CollectionRuleTriggerOptions.Type),
                triggerType,
                nameof(CollectionRuleTriggerOptions.Settings),
                subSchema);

            settingsProperty.Reference = context.AddTypeIfNotExist <TOptions>();

            triggerTypeSchema.Enumeration.Add(triggerType);
        }