Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix of documentation generation for aggregation #184

Merged
merged 2 commits into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions src/MMLib.SwaggerForOcelot/Aggregates/RouteDocs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public string GetSummary()
/// </summary>
public OpenApiResponse GetResponse()
{
var response = Docs[PathKey].SelectToken("responses.200")?.ToObject(typeof(Response), _serializer) as Response;
var response = Docs[PathKey]?.SelectToken("responses.200")?.ToObject(typeof(Response), _serializer) as Response;

return new OpenApiResponse()
{
Expand All @@ -134,22 +134,28 @@ public OpenApiResponse GetResponse()

private Dictionary<string, OpenApiMediaType> CreateContent(Response response)
{
OpenApiMediaTypeEx content = response?.Content[MediaTypeNames.Application.Json];
var ret = new Dictionary<string, OpenApiMediaType>();
if (response?.Content is null)
{
return ret;
}

if (content != null)
OpenApiMediaTypeEx content = response.Content[MediaTypeNames.Application.Json];
if (content == null)
{
if (!content.SchemaExt.IsReference)
{
content.SetSchema();
}
else
{
FindSchema(content);
}
return ret;
}

ret.Add(MediaTypeNames.Application.Json, content);
if (!content.SchemaExt.IsReference)
{
content.SetSchema();
}
else
{
FindSchema(content);
}

ret.Add(MediaTypeNames.Application.Json, content);

return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion src/MMLib.SwaggerForOcelot/MMLib.SwaggerForOcelot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<Version>4.4.1</Version>
<Version>4.4.2</Version>
<Authors>Milan Martiniak</Authors>
<Company>MMLib</Company>
<Description>Swagger generator for Ocelot downstream services.</Description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class RoutesDocumentationProviderShould
[InlineData("serviceWithMoreSimpleParameter1", "serviceWithMoreSimpleParameter2", "/{id}/{message}")]
[InlineData("serviceWithMoreSimpleParameter1", "serviceWithMoreSimpleParameterAnotherNames", "/{id}/{message}", "{id}-{idcko};{message}-{sprava}")]
[InlineData("moreMethod1", "moreMethod2")]
[InlineData("withoutcontent1", "withoutcontent2")]
public async Task GetDocs(string firstService, string secondService, string parameters = null, string paramsMap = null)
{
RoutesDocumentationProvider provider = await CreateProviderAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,32 @@
}
}
},
"/api/withoutcontent1/endpoint1": {
"get": {
"tags": [
"withoutcontent1"
],
"summary": "withoutcontent1 - endpoint 1",
"responses": {
"200": {
"description": "Success"
}
}
}
},
"/api/withoutcontent2/endpoint1": {
"get": {
"tags": [
"withoutcontent2"
],
"summary": "withoutcontent2 - endpoint 1",
"responses": {
"200": {
"description": "Success"
}
}
}
},
"/api/serviceWithSimpleParameter1/endpoint1/{id}": {
"get": {
"tags": [
Expand Down