コード例 #1
0
        public ChainableSchemaGenerator Add(ChainableSchemaGenerator chainableSchemaGenerator)
        {
            var tail = this;

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

            tail.Next = chainableSchemaGenerator;
            return(this);
        }
コード例 #2
0
        public SchemaGenerator(SchemaGeneratorOptions options, JsonSerializerSettings serializerSettings)
        {
            options = options ?? new SchemaGeneratorOptions();

            // 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();

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