Esempio n. 1
0
        protected async Task ResponseWithAsyncApiJson(HttpResponse response, AsyncApiDocument swagger)
        {
            response.StatusCode  = 200;
            response.ContentType = "application/json;charset=utf-8";
            StringBuilder sb = new StringBuilder();

            using (StringWriter writer = new StringWriter(sb))
            {
                AsyncApiSerializer.Serialize(writer, swagger);
                await response.WriteAsync(sb.ToString(), new UTF8Encoding(false));
            }
        }
Esempio n. 2
0
        public AsyncApiDocument GetAsyncApi(string documentName, string host = null, string basePath = null,
                                            string[] schemes = null)
        {
            AsyncApiDocInfo info;

            if (!Options.AsyncApiDocs.TryGetValue(documentName, out info))
            {
                throw new UnknownAsyncApiDocument(documentName);
            }

            ISchemaRegistry schemaRegistry = new AsyncApiSchemaRegistry(JsonSerializerSettings);
            var             asyncApiDoc    = new AsyncApiDocument
            {
                Info               = info.Info,
                Channels           = GetChannels(info.AsyncApiType, schemaRegistry),
                DefaultContentType = "application/json", // TODO.
                Components         = new AsyncApiComponents {
                    Schemas = schemaRegistry.Definitions
                }
            };

            return(asyncApiDoc);
        }