add some documentation to swagger about return types & fix get templates not returning
This commit is contained in:
1
src/.idea/.idea.Kynareth/.idea/vcs.xml
generated
1
src/.idea/.idea.Kynareth/.idea/vcs.xml
generated
@@ -1,7 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
|
||||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -17,15 +17,21 @@ public class ImageGenerationController : BaseController<ImageGenerationControlle
|
|||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[EndpointMetrics("image.generate.get.templates")]
|
[EndpointMetrics("image.generate.get.templates")]
|
||||||
|
[ProducesResponseType(typeof(IEnumerable<ImageGenerationEndpointRead>), StatusCodes.Status200OK)]
|
||||||
public Task<object> GetTemplates()
|
public Task<object> GetTemplates()
|
||||||
{
|
{
|
||||||
string serialized = JsonSerializer.Serialize(ImageManager.GetGenerationEndpoints());
|
string serialized = JsonSerializer.Serialize(ImageManager.GetGenerationEndpoints());
|
||||||
|
|
||||||
return Task.FromResult(HttpContext.Send(EventResult.FromSuccess()));
|
return Task.FromResult(HttpContext.Send(EventResult.FromSuccess(serialized)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{template}")]
|
[HttpGet("{template}")]
|
||||||
[EndpointMetrics("image.generate.generate")]
|
[EndpointMetrics("image.generate.generate")]
|
||||||
|
[ProducesResponseType(typeof(Stream), StatusCodes.Status200OK, "image/png")]
|
||||||
|
[ProducesResponseType(typeof(Stream), StatusCodes.Status200OK, "image/gif")]
|
||||||
|
[ProducesResponseType(typeof(EventResult), StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(typeof(EventResult), StatusCodes.Status404NotFound)]
|
||||||
|
[ProducesResponseType(typeof(EventResult), StatusCodes.Status500InternalServerError)]
|
||||||
public async Task<object> GetImageAsync(string template, [FromQuery(Name = "source")] string[] sources, [FromQuery] string variant = null)
|
public async Task<object> GetImageAsync(string template, [FromQuery(Name = "source")] string[] sources, [FromQuery] string variant = null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ public class ImageManipulationController : BaseController<ImageManipulationContr
|
|||||||
/// ---------- ///
|
/// ---------- ///
|
||||||
[HttpGet("magik")]
|
[HttpGet("magik")]
|
||||||
[EndpointMetrics("image.manipulation.magik")]
|
[EndpointMetrics("image.manipulation.magik")]
|
||||||
|
[ProducesResponseType(typeof(Stream), StatusCodes.Status200OK, "image/png")]
|
||||||
|
[ProducesResponseType(typeof(Stream), StatusCodes.Status200OK, "image/gif")]
|
||||||
|
[ProducesResponseType(typeof(EventResult), StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(typeof(EventResult), StatusCodes.Status500InternalServerError)]
|
||||||
public async Task<object> MagikImage([FromQuery] string image)
|
public async Task<object> MagikImage([FromQuery] string image)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -29,7 +33,7 @@ public class ImageManipulationController : BaseController<ImageManipulationContr
|
|||||||
return HttpContext.SendStream(data, contentType);
|
return HttpContext.SendStream(data, contentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
return HttpContext.Send(EventResult.FromFailure("No image has been provided"), System.Net.HttpStatusCode.InternalServerError);
|
return HttpContext.Send(EventResult.FromFailure("No image has been provided"), System.Net.HttpStatusCode.BadRequest);
|
||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
@@ -46,6 +50,10 @@ public class ImageManipulationController : BaseController<ImageManipulationContr
|
|||||||
/// ------------- ///
|
/// ------------- ///
|
||||||
[HttpGet("{template}")]
|
[HttpGet("{template}")]
|
||||||
[EndpointMetrics("image.manipulation.generate")]
|
[EndpointMetrics("image.manipulation.generate")]
|
||||||
|
[ProducesResponseType(typeof(Stream), StatusCodes.Status200OK, "image/png")]
|
||||||
|
[ProducesResponseType(typeof(EventResult), StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(typeof(EventResult), StatusCodes.Status404NotFound)]
|
||||||
|
[ProducesResponseType(typeof(EventResult), StatusCodes.Status500InternalServerError)]
|
||||||
public async Task<object> GenerateMemeAsync(string template, [FromQuery] string[] text)
|
public async Task<object> GenerateMemeAsync(string template, [FromQuery] string[] text)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -64,7 +72,7 @@ public class ImageManipulationController : BaseController<ImageManipulationContr
|
|||||||
return result as IResult;
|
return result as IResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
return HttpContext.Send(EventResult.FromFailure("No template has been provided"), System.Net.HttpStatusCode.InternalServerError);
|
return HttpContext.Send(EventResult.FromFailure("No template has been provided"), System.Net.HttpStatusCode.BadRequest);
|
||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user