예제 #1
0
 /// <summary>Initializes a new instance of the <see cref="DocumentProcessorContext" /> class.</summary>
 /// <param name="document">The document.</param>
 /// <param name="controllerTypes">The controller types.</param>
 /// <param name="schemaResolver">The schema resolver.</param>
 /// <param name="schemaGenerator">The schema generator.</param>
 public DocumentProcessorContext(SwaggerDocument document, IEnumerable <Type> controllerTypes, JsonSchemaResolver schemaResolver, JsonSchemaGenerator schemaGenerator)
 {
     Document        = document;
     ControllerTypes = controllerTypes;
     SchemaResolver  = schemaResolver;
     SchemaGenerator = schemaGenerator;
 }
예제 #2
0
 /// <summary>Initializes a new instance of the <see cref="OpenApiDocumentGenerator"/> class.</summary>
 /// <param name="settings">The settings.</param>
 /// <param name="schemaResolver">The schema resolver.</param>
 public OpenApiDocumentGenerator(OpenApiDocumentGeneratorSettings settings, JsonSchemaResolver schemaResolver)
 {
     _schemaResolver = schemaResolver;
     _settings       = settings;
 }
예제 #3
0
 public JsonSchemaWriter(JsonWriter writer, JsonSchemaResolver resolver)
 {
   ValidationUtils.ArgumentNotNull(writer, "writer");
   _writer = writer;
   _resolver = resolver;
 }
예제 #4
0
    /// <summary>
    /// Reads a <see cref="JsonSchema"/> from the specified <see cref="JsonReader"/>.
    /// </summary>
    /// <param name="reader">The <see cref="JsonReader"/> containing the JSON Schema to read.</param>
    /// <param name="resolver">The <see cref="JsonSchemaResolver"/> to use when resolving schema references.</param>
    /// <returns>The <see cref="JsonSchema"/> object representing the JSON Schema.</returns>
    public static JsonSchema Read(JsonReader reader, JsonSchemaResolver resolver)
    {
      ValidationUtils.ArgumentNotNull(reader, "reader");
      ValidationUtils.ArgumentNotNull(resolver, "resolver");

      JsonSchemaBuilder builder = new JsonSchemaBuilder(resolver);
      return builder.Read(reader);
    }
예제 #5
0
    /// <summary>
    /// Writes this schema to a <see cref="JsonWriter"/> using the specified <see cref="JsonSchemaResolver"/>.
    /// </summary>
    /// <param name="writer">A <see cref="JsonWriter"/> into which this method will write.</param>
    /// <param name="resolver">The resolver used.</param>
    public void WriteTo(JsonWriter writer, JsonSchemaResolver resolver)
    {
      ValidationUtils.ArgumentNotNull(writer, "writer");
      ValidationUtils.ArgumentNotNull(resolver, "resolver");

      JsonSchemaWriter schemaWriter = new JsonSchemaWriter(writer, resolver);
      schemaWriter.WriteSchema(this);
    }
예제 #6
0
        /// <summary>Gets the schema for the mapped type.</summary>
        /// <typeparam name="TSchemaType">The type of the schema type.</typeparam>
        /// <param name="schemaGenerator">The schema generator.</param>
        /// <param name="schemaResolver">The schema resolver.</param>
        /// <returns>The schema.</returns>
        public virtual TSchemaType GetSchema <TSchemaType>(JsonSchemaGenerator schemaGenerator, JsonSchemaResolver schemaResolver)
            where TSchemaType : JsonSchema4, new()
        {
            var schema = new TSchemaType();

            _transformer(schema);
            return(schema);
        }
예제 #7
0
 /// <summary>
 /// Generate a <see cref="JsonSchema"/> from the specified type.
 /// </summary>
 /// <param name="type">The type to generate a <see cref="JsonSchema"/> from.</param>
 /// <param name="resolver">The <see cref="JsonSchemaResolver"/> used to resolve schema references.</param>
 /// <returns>A <see cref="JsonSchema"/> generated from the specified type.</returns>
 public JsonSchema Generate(Type type, JsonSchemaResolver resolver)
 {
     return(this.Generate(type, resolver, false));
 }
예제 #8
0
 public JsonSchemaBuilder(JsonSchemaResolver resolver)
 {
   _stack = new List<JsonSchema>();
   _documentSchemas = new Dictionary<string, JsonSchema>();
   _resolver = resolver;
 }
예제 #9
0
        /// <summary>Gets the schema.</summary>
        /// <typeparam name="TSchemaType">The schema type.</typeparam>
        /// <param name="schemaGenerator">The schema generator.</param>
        /// <param name="schemaResolver">The schema resolver.</param>
        /// <returns></returns>
        public virtual TSchemaType GetSchema <TSchemaType>(JsonSchemaGenerator schemaGenerator, JsonSchemaResolver schemaResolver) where TSchemaType : JsonSchema4, new()
        {
            if (!schemaResolver.HasSchema(MappedType, false))
            {
                schemaResolver.AddSchema(MappedType, false, _schemaFactory(schemaGenerator, schemaResolver));
            }

            return(null);
        }
예제 #10
0
            public override Task GenerateAsync <TSchemaType>(Type type, IEnumerable <Attribute> parentAttributes, TSchemaType schema, JsonSchemaResolver schemaResolver)
            {
                var v = base.GenerateAsync(type, parentAttributes, schema, schemaResolver);

                schema.AllowAdditionalProperties = true;
                return(v);
            }
예제 #11
0
 public Class130(JsonSchemaResolver resolver)
 {
     this.jsonSchemaResolver_0 = resolver;
 }
예제 #12
0
 public Class125(JsonWriter writer, JsonSchemaResolver resolver)
 {
     Class203.smethod_2(writer, "writer");
     this.jsonWriter_0         = writer;
     this.jsonSchemaResolver_0 = resolver;
 }
예제 #13
0
 /// <summary>Initializes a new instance of the <see cref="AspNetCoreOperationProcessorContext" /> class.</summary>
 /// <param name="document">The document.</param>
 /// <param name="operationDescription">The operation description.</param>
 /// <param name="controllerType">Type of the controller.</param>
 /// <param name="methodInfo">The method information.</param>
 /// <param name="swaggerGenerator">The swagger generator.</param>
 /// <param name="schemaResolver">The schema resolver.</param>
 /// <param name="allOperationDescriptions">All operation descriptions.</param>
 /// <param name="schemaGenerator">The schema generator.</param>
 public AspNetCoreOperationProcessorContext(SwaggerDocument document, SwaggerOperationDescription operationDescription, Type controllerType, MethodInfo methodInfo, SwaggerGenerator swaggerGenerator, JsonSchemaGenerator schemaGenerator, JsonSchemaResolver schemaResolver, IList <SwaggerOperationDescription> allOperationDescriptions)
     : base(document, operationDescription, controllerType, methodInfo, swaggerGenerator, schemaGenerator, schemaResolver, allOperationDescriptions)
 {
 }
예제 #14
0
        public void ExtendedComplex()
        {
            string first = @"{
  ""id"":""first"",
  ""type"":""object"",
  ""properties"":
  {
    ""firstproperty"":{""type"":""string""},
    ""secondproperty"":{""type"":""string"",""maxLength"":10},
    ""thirdproperty"":{
      ""type"":""object"",
      ""properties"":
      {
        ""thirdproperty_firstproperty"":{""type"":""string"",""maxLength"":10,""minLength"":7}
      }
    }
  },
  ""additionalProperties"":{}
}";

            string second = @"{
  ""id"":""second"",
  ""type"":""object"",
  ""extends"":{""$ref"":""first""},
  ""properties"":
  {
    ""secondproperty"":{""type"":""any""},
    ""thirdproperty"":{
      ""extends"":{
        ""properties"":
        {
          ""thirdproperty_firstproperty"":{""maxLength"":9,""minLength"":6,""pattern"":""hi2u""}
        },
        ""additionalProperties"":{""maxLength"":9,""minLength"":6,""enum"":[""one"",""two""]}
      },
      ""type"":""object"",
      ""properties"":
      {
        ""thirdproperty_firstproperty"":{""pattern"":""hi""}
      },
      ""additionalProperties"":{""type"":""string"",""enum"":[""two"",""three""]}
    },
    ""fourthproperty"":{""type"":""string""}
  },
  ""additionalProperties"":false
}";

            JsonSchemaResolver resolver     = new JsonSchemaResolver();
            JsonSchema         firstSchema  = JsonSchema.Parse(first, resolver);
            JsonSchema         secondSchema = JsonSchema.Parse(second, resolver);

            JsonSchemaModelBuilder modelBuilder = new JsonSchemaModelBuilder();

            string json = @"{
  'firstproperty':'blahblahblahblahblahblah',
  'secondproperty':'secasecasecasecaseca',
  'thirdproperty':{
    'thirdproperty_firstproperty':'aaa',
    'additional':'three'
  }
}";

            Json.Schema.ValidationEventArgs validationEventArgs = null;
            List <string> errors = new List <string>();

            JsonValidatingReader reader = new JsonValidatingReader(new JsonTextReader(new StringReader(json)));

            reader.ValidationEventHandler += (sender, args) => { validationEventArgs = args; errors.Add(validationEventArgs.Message); };
            reader.Schema = secondSchema;

            Assert.IsTrue(reader.Read());
            Assert.AreEqual(JsonToken.StartObject, reader.TokenType);

            Assert.IsTrue(reader.Read());
            Assert.AreEqual(JsonToken.PropertyName, reader.TokenType);
            Assert.AreEqual("firstproperty", reader.Value.ToString());
            Assert.AreEqual(null, validationEventArgs);

            Assert.IsTrue(reader.Read());
            Assert.AreEqual(JsonToken.String, reader.TokenType);
            Assert.AreEqual("blahblahblahblahblahblah", reader.Value.ToString());

            Assert.IsTrue(reader.Read());
            Assert.AreEqual(JsonToken.PropertyName, reader.TokenType);
            Assert.AreEqual("secondproperty", reader.Value.ToString());

            Assert.IsTrue(reader.Read());
            Assert.AreEqual(JsonToken.String, reader.TokenType);
            Assert.AreEqual("secasecasecasecaseca", reader.Value.ToString());
            Assert.AreEqual(1, errors.Count);
            Assert.AreEqual("String 'secasecasecasecaseca' exceeds maximum length of 10. Line 3, position 41.", errors[0]);

            Assert.IsTrue(reader.Read());
            Assert.AreEqual(JsonToken.PropertyName, reader.TokenType);
            Assert.AreEqual("thirdproperty", reader.Value.ToString());
            Assert.AreEqual(1, errors.Count);

            Assert.IsTrue(reader.Read());
            Assert.AreEqual(JsonToken.StartObject, reader.TokenType);
            Assert.AreEqual(1, errors.Count);

            Assert.IsTrue(reader.Read());
            Assert.AreEqual(JsonToken.PropertyName, reader.TokenType);
            Assert.AreEqual("thirdproperty_firstproperty", reader.Value.ToString());
            Assert.AreEqual(1, errors.Count);

            Assert.IsTrue(reader.Read());
            Assert.AreEqual(JsonToken.String, reader.TokenType);
            Assert.AreEqual("aaa", reader.Value.ToString());
            Assert.AreEqual(4, errors.Count);
            Assert.AreEqual("String 'aaa' is less than minimum length of 7. Line 5, position 39.", errors[1]);
            Assert.AreEqual("String 'aaa' does not match regex pattern 'hi'. Line 5, position 39.", errors[2]);
            Assert.AreEqual("String 'aaa' does not match regex pattern 'hi2u'. Line 5, position 39.", errors[3]);

            Assert.IsTrue(reader.Read());
            Assert.AreEqual(JsonToken.PropertyName, reader.TokenType);
            Assert.AreEqual("additional", reader.Value.ToString());
            Assert.AreEqual(4, errors.Count);

            Assert.IsTrue(reader.Read());
            Assert.AreEqual(JsonToken.String, reader.TokenType);
            Assert.AreEqual("three", reader.Value.ToString());
            Assert.AreEqual(5, errors.Count);
            Assert.AreEqual("String 'three' is less than minimum length of 6. Line 6, position 24.", errors[4]);

            Assert.IsTrue(reader.Read());
            Assert.AreEqual(JsonToken.EndObject, reader.TokenType);

            Assert.IsTrue(reader.Read());
            Assert.AreEqual(JsonToken.EndObject, reader.TokenType);

            Assert.IsFalse(reader.Read());
        }
예제 #15
0
        public void Extends()
        {
            string             json;
            JsonSchemaResolver resolver = new JsonSchemaResolver();

            json = @"{
  ""id"":""first"",
  ""type"":""object"",
  ""additionalProperties"":{}
}";

            JsonSchema first = JsonSchema.Parse(json, resolver);

            json =
                @"{
  ""id"":""second"",
  ""type"":""object"",
  ""extends"":{""$ref"":""first""},
  ""additionalProperties"":{""type"":""string""}
}";

            JsonSchema second = JsonSchema.Parse(json, resolver);

            Assert.AreEqual(first, second.Extends[0]);

            json =
                @"{
  ""id"":""third"",
  ""type"":""object"",
  ""extends"":{""$ref"":""second""},
  ""additionalProperties"":false
}";

            JsonSchema third = JsonSchema.Parse(json, resolver);

            Assert.AreEqual(second, third.Extends[0]);
            Assert.AreEqual(first, third.Extends[0].Extends[0]);

            StringWriter   writer     = new StringWriter();
            JsonTextWriter jsonWriter = new JsonTextWriter(writer);

            jsonWriter.Formatting = Formatting.Indented;

            third.WriteTo(jsonWriter, resolver);

            string writtenJson = writer.ToString();

            Assert.AreEqual(@"{
  ""id"": ""third"",
  ""type"": ""object"",
  ""additionalProperties"": false,
  ""extends"": {
    ""$ref"": ""second""
  }
}", writtenJson);

            StringWriter   writer1     = new StringWriter();
            JsonTextWriter jsonWriter1 = new JsonTextWriter(writer1);

            jsonWriter1.Formatting = Formatting.Indented;

            third.WriteTo(jsonWriter1);

            writtenJson = writer1.ToString();
            Assert.AreEqual(@"{
  ""id"": ""third"",
  ""type"": ""object"",
  ""additionalProperties"": false,
  ""extends"": {
    ""id"": ""second"",
    ""type"": ""object"",
    ""additionalProperties"": {
      ""type"": ""string""
    },
    ""extends"": {
      ""id"": ""first"",
      ""type"": ""object"",
      ""additionalProperties"": {}
    }
  }
}", writtenJson);
        }
        /// <summary>Gets the schema for the mapped type.</summary>
        /// <typeparam name="TSchemaType">The type of the schema type.</typeparam>
        /// <param name="schema">The schema.</param>
        /// <param name="schemaGenerator">The schema generator.</param>
        /// <param name="schemaResolver">The schema resolver.</param>
        /// <returns>The schema.</returns>
#pragma warning disable 1998
        public async Task GenerateSchemaAsync <TSchemaType>(TSchemaType schema, JsonSchemaGenerator schemaGenerator, JsonSchemaResolver schemaResolver)
#pragma warning restore 1998
            where TSchemaType : JsonSchema4, new()
        {
            _transformer(schema);
        }
예제 #17
0
        /// <summary>Generates the properties for the given type and schema.</summary>
        /// <param name="typeDescription">The type desription.</param>
        /// <param name="schema">The properties</param>
        /// <param name="schemaResolver">The schema resolver.</param>
        /// <returns></returns>
        protected override void GenerateObject(JsonSchema schema, JsonTypeDescription typeDescription, JsonSchemaResolver schemaResolver)
        {
            if (_isRootType)
            {
                _isRootType = false;
                base.GenerateObject(schema, typeDescription, schemaResolver);
                _isRootType = true;
            }
            else
            {
                if (!schemaResolver.HasSchema(typeDescription.ContextualType.OriginalType, false))
                {
                    _isRootType = true;
                    Generate(typeDescription.ContextualType.OriginalType, schemaResolver);
                    _isRootType = false;
                }

                schema.Reference = schemaResolver.GetSchema(typeDescription.ContextualType.OriginalType, false);
            }
        }
예제 #18
0
 public JsonSchemaWriter(JsonWriter writer, JsonSchemaResolver resolver)
 {
     ValidationUtils.ArgumentNotNull(writer, nameof(writer));
     _writer   = writer;
     _resolver = resolver;
 }
예제 #19
0
        public static async Task <JsonSchema4> GetErrorDtoSchemaAsync(this JsonSchemaGenerator schemaGenerator, JsonSchemaResolver resolver)
        {
            var errorType = typeof(ErrorDto);

            return(await schemaGenerator.GenerateWithReference <JsonSchema4>(errorType, Enumerable.Empty <Attribute>(), resolver));
        }
예제 #20
0
 /// <summary>Initializes a new instance of the <see cref="SwaggerGenerator"/> class.</summary>
 /// <param name="schemaGenerator">The schema generator.</param>
 /// <param name="schemaGeneratorSettings">The schema generator settings.</param>
 /// <param name="schemaResolver">The schema resolver.</param>
 public SwaggerGenerator(JsonSchemaGenerator schemaGenerator, JsonSchemaGeneratorSettings schemaGeneratorSettings, JsonSchemaResolver schemaResolver)
 {
     _schemaGenerator = schemaGenerator;
     _schemaResolver  = schemaResolver;
     _settings        = schemaGeneratorSettings;
 }
        public void ExtendedComplex()
        {
            string first = @"{
  ""id"":""first"",
  ""type"":""object"",
  ""properties"":
  {
    ""firstproperty"":{""type"":""string""},
    ""secondproperty"":{""type"":""string"",""maxLength"":10},
    ""thirdproperty"":{
      ""type"":""object"",
      ""properties"":
      {
        ""thirdproperty_firstproperty"":{""type"":""string"",""maxLength"":10,""minLength"":7}
      }
    }
  },
  ""additionalProperties"":{}
}";

            string second = @"{
  ""id"":""second"",
  ""type"":""object"",
  ""extends"":{""$ref"":""first""},
  ""properties"":
  {
    ""secondproperty"":{""type"":""any""},
    ""thirdproperty"":{
      ""extends"":{
        ""properties"":
        {
          ""thirdproperty_firstproperty"":{""maxLength"":9,""minLength"":6,""pattern"":""hi2u""}
        },
        ""additionalProperties"":{""maxLength"":9,""minLength"":6,""enum"":[""one"",""two""]}
      },
      ""type"":""object"",
      ""properties"":
      {
        ""thirdproperty_firstproperty"":{""pattern"":""hi""}
      },
      ""additionalProperties"":{""type"":""string"",""enum"":[""two"",""three""]}
    },
    ""fourthproperty"":{""type"":""string""}
  },
  ""additionalProperties"":false
}";

            JsonSchemaResolver resolver     = new JsonSchemaResolver();
            JsonSchema         firstSchema  = JsonSchema.Parse(first, resolver);
            JsonSchema         secondSchema = JsonSchema.Parse(second, resolver);

            JsonSchemaModelBuilder modelBuilder = new JsonSchemaModelBuilder();

            JsonSchemaModel model = modelBuilder.Build(secondSchema);

            Assert.AreEqual(4, model.Properties.Count);

            Assert.AreEqual(JsonSchemaType.String, model.Properties["firstproperty"].Type);

            Assert.AreEqual(JsonSchemaType.String, model.Properties["secondproperty"].Type);
            Assert.AreEqual(10, model.Properties["secondproperty"].MaximumLength);
            Assert.AreEqual(null, model.Properties["secondproperty"].Enum);
            Assert.AreEqual(null, model.Properties["secondproperty"].Patterns);

            Assert.AreEqual(JsonSchemaType.Object, model.Properties["thirdproperty"].Type);
            Assert.AreEqual(3, model.Properties["thirdproperty"].AdditionalProperties.Enum.Count);
            Assert.AreEqual("two", (string)model.Properties["thirdproperty"].AdditionalProperties.Enum[0]);
            Assert.AreEqual("three", (string)model.Properties["thirdproperty"].AdditionalProperties.Enum[1]);
            Assert.AreEqual("one", (string)model.Properties["thirdproperty"].AdditionalProperties.Enum[2]);

            Assert.AreEqual(JsonSchemaType.String, model.Properties["thirdproperty"].Properties["thirdproperty_firstproperty"].Type);
            Assert.AreEqual(9, model.Properties["thirdproperty"].Properties["thirdproperty_firstproperty"].MaximumLength);
            Assert.AreEqual(7, model.Properties["thirdproperty"].Properties["thirdproperty_firstproperty"].MinimumLength);
            Assert.AreEqual(2, model.Properties["thirdproperty"].Properties["thirdproperty_firstproperty"].Patterns.Count);
            Assert.AreEqual("hi", model.Properties["thirdproperty"].Properties["thirdproperty_firstproperty"].Patterns[0]);
            Assert.AreEqual("hi2u", model.Properties["thirdproperty"].Properties["thirdproperty_firstproperty"].Patterns[1]);
            Assert.AreEqual(null, model.Properties["thirdproperty"].Properties["thirdproperty_firstproperty"].Properties);
            Assert.AreEqual(null, model.Properties["thirdproperty"].Properties["thirdproperty_firstproperty"].Items);
            Assert.AreEqual(null, model.Properties["thirdproperty"].Properties["thirdproperty_firstproperty"].AdditionalProperties);
        }
예제 #22
0
 /// <summary>Initializes a new instance of the <see cref="SchemaProcessorContext" /> class.</summary>
 /// <param name="schema">The JSON Schema.</param>
 /// <param name="resolver">The resolver.</param>
 /// <param name="generator">The generator.</param>
 public SchemaProcessorContext(JsonSchema4 schema, JsonSchemaResolver resolver, JsonSchemaGenerator generator)
 {
     Schema    = schema;
     Resolver  = resolver;
     Generator = generator;
 }
예제 #23
0
    /// <summary>
    /// Parses the specified json.
    /// </summary>
    /// <param name="json">The json.</param>
    /// <param name="resolver">The resolver.</param>
    /// <returns>A <see cref="JsonSchema"/> populated from the string that contains JSON.</returns>
    public static JsonSchema Parse(string json, JsonSchemaResolver resolver)
    {
      ValidationUtils.ArgumentNotNull(json, "json");

      JsonReader reader = new JsonTextReader(new StringReader(json));

      return Read(reader, resolver);
    }
예제 #24
0
        /// <summary>Generates the properties for the given type and schema.</summary>
        /// <param name="type">The types.</param>
        /// <param name="typeDescription">The type desription.</param>
        /// <param name="schema">The properties</param>
        /// <param name="schemaResolver">The schema resolver.</param>
        /// <returns></returns>
        protected override async Task GenerateObjectAsync(Type type, JsonTypeDescription typeDescription, JsonSchema4 schema, JsonSchemaResolver schemaResolver)
        {
            if (_isRootType)
            {
                _isRootType = false;
                await base.GenerateObjectAsync(type, typeDescription, schema, schemaResolver);

                _isRootType = true;
            }
            else
            {
                if (!schemaResolver.HasSchema(type, false))
                {
                    _isRootType = true;
                    await GenerateAsync(type, schemaResolver);

                    _isRootType = false;
                }

                schema.Reference = schemaResolver.GetSchema(type, false);
            }
        }
예제 #25
0
 /// <summary>Initializes a new instance of the <see cref="SwaggerGenerator"/> class.</summary>
 /// <param name="schemaGenerator">The schema generator.</param>
 /// <param name="schemaGeneratorSettings">The schema generator settings.</param>
 /// <param name="schemaResolver">The schema resolver.</param>
 public SwaggerGenerator(JsonSchemaGenerator schemaGenerator, JsonSchemaGeneratorSettings schemaGeneratorSettings, JsonSchemaResolver schemaResolver)
 {
     _schemaResolver = schemaResolver;
     _schemaGenerator = schemaGenerator;
     _settings = schemaGeneratorSettings;
 }
예제 #26
0
        public static FileContent GetFile(string requestPath, HubApiConfiguration hubApiConfiguration)
        {
            var    basePath = hubApiConfiguration.ApiInfo?.HubApiEndpoint ?? "/hubapi";
            string filePath;

            if (!basePath.StartsWith("/"))
            {
                basePath = "/" + basePath;
            }

            if (!requestPath.StartsWith(basePath))
            {
                return(new FileContent());
            }

            if (requestPath.EndsWith("/"))
            {
                requestPath = requestPath.Substring(0, requestPath.Length - 1);
            }
            if (requestPath.EndsWith("api.json"))
            {
                var schemaSettings = new JsonSchemaGeneratorSettings
                {
                    SerializerSettings               = JsonSerializerSettings,
                    GenerateExamples                 = true,
                    SchemaType                       = SchemaType.JsonSchema,
                    GenerateAbstractSchemas          = false,
                    DefaultReferenceTypeNullHandling = ReferenceTypeNullHandling.NotNull
                };

                var schema = new JsonSchema();

                var resolver  = new JsonSchemaResolver(schema, schemaSettings);
                var generator = new JsonSchemaGenerator(schemaSettings);

                generator.Generate(schema, typeof(object), resolver);

                var jDoc = JObject.FromObject(hubApiConfiguration);
                // generate schema definitions
                foreach (var hub in hubApiConfiguration.Hubs)
                {
                    foreach (var hubMethod in hub.Methods)
                    {
                        if (hubMethod.Response.Type != typeof(void) && hubMethod.Response.Type != typeof(Task))
                        {
                            generator.Generate(hubMethod.Response.Type, resolver);
                        }

                        foreach (var parameter in hubMethod.Parameters)
                        {
                            generator.Generate(parameter.Type, resolver);
                        }
                    }

                    foreach (var clientMethod in hub.ClientMethods)
                    {
                        if (clientMethod.Response.Type != typeof(void) && clientMethod.Response.Type != typeof(Task))
                        {
                            generator.Generate(clientMethod.Response.Type, resolver);
                        }
                        foreach (var parameter in clientMethod.Parameters)
                        {
                            generator.Generate(parameter.Type, resolver);
                        }
                    }
                }

                var schemaJObject = JObject.Parse(schema.ToJson());
                jDoc["definitions"] = schemaJObject["definitions"];

                var buffer = Encoding.UTF8.GetBytes(jDoc.ToString(Formatting.None));

                var fileResult = new FileContent(requestPath, buffer);

                return(fileResult);
            }
            if (requestPath.Equals(basePath))
            {
                filePath = "index.html";
            }
            else
            {
                filePath = requestPath.Substring(basePath.Length + 1);
                filePath = filePath.Replace("/", ".");
            }
            var embeddedResource = $"{typeof(HubApiConfiguration).Namespace}.web.{filePath}";

            using (var stream = typeof(HubApiConfiguration).Assembly.GetManifestResourceStream(embeddedResource))
            {
                byte[] buffer = null;
                if (stream != null)
                {
                    buffer = ReadToEnd(stream);
                }
                var fileResult = new FileContent(filePath, buffer);
                return(fileResult);
            }
        }