Ejemplo n.º 1
0
        public ChainableSchemaGenerator Add(ChainableSchemaGenerator chainableSchemaGenerator)
        {
            var tail = this;

            while (tail.Next != null)
            {
                tail = tail.Next;
            }

            tail.Next = chainableSchemaGenerator;
            return(this);
        }
Ejemplo n.º 2
0
        public SchemaGenerator(
            JsonSerializerSettings serializerSettings,
            SchemaGeneratorOptions options)
        {
            // NOTE: An OpenApiSchema MAY be used to describe both JSON and non-JSON media types. However, this implementation of ISchemaGenerator
            // is optimized for JSON and therefore couples to several JSON.NET abstractions so that it can provide accurate descriptions of types
            // in their serialized form.
            serializerSettings = serializerSettings ?? new JsonSerializerSettings();
            var contractResolver = serializerSettings.ContractResolver ?? new DefaultContractResolver();

            options = options ?? new SchemaGeneratorOptions();

            _generatorChain = new TypeSpecificSchemaGenerator(contractResolver, this, options)
                              .Add(new FileSchemaGenerator(contractResolver, this, options))
                              .Add(new ReferencedSchemaGenerator(contractResolver, this, options))
                              .Add(new PolymorphicSchemaGenerator(contractResolver, this, options))
                              .Add(new PrimitiveSchemaGenerator(contractResolver, this, serializerSettings, options))
                              .Add(new DictionarySchemaGenerator(contractResolver, this, options))
                              .Add(new ArraySchemaGenerator(contractResolver, this, serializerSettings, options))
                              .Add(new ObjectSchemaGenerator(contractResolver, this, serializerSettings, options))
                              .Add(new CustomSchemaGenerator(contractResolver, this, options));
        }