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

[DevOps] .spectral.yaml 수정 - 404, 400 정의 #268 #305

Merged
merged 3 commits into from
Sep 7, 2024
Merged
Changes from 2 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
22 changes: 22 additions & 0 deletions .spectral.yaml
Original file line number Diff line number Diff line change
@@ -81,3 +81,25 @@ rules:
- field: 'content'
function: truthy
message: Content is required

# Ensure endpoints with path variables define a 404 response
# path에 path variable이 있다면 404 응답 코드가 있어야 함
path-variables-require-404:
description: Path variables must include a 404 response
severity: error
given: $.paths[*][*].parameters[?(@.in == 'path')]^^
then:
- field: responses.404
function: truthy
message: Response 404 is required

# Ensure POST, PUT, PATCH methods define a 400 response
# verb가 POST, PUT, PATCH일 경우 400 응답코드가 있어야 함
post-put-patch-require-400:
description: POST, PUT, PATCH methods must include a 400 response
given: $.paths[*][?(@property == 'post' || @property == 'put' || @property == 'patch')]
severity: error
then:
- field: responses.400
function: truthy
message: Response 400 is required
2 changes: 2 additions & 0 deletions src/AzureOpenAIProxy.ApiApp/Endpoints/AdminEventEndpoints.cs
Original file line number Diff line number Diff line change
@@ -116,6 +116,7 @@ public static RouteHandlerBuilder AddGetAdminEvent(this WebApplication app)
})
.Produces<AdminEventDetails>(statusCode: StatusCodes.Status200OK, contentType: "application/json")
.Produces(statusCode: StatusCodes.Status401Unauthorized)
.Produces(statusCode: StatusCodes.Status404NotFound)
.Produces<string>(statusCode: StatusCodes.Status500InternalServerError, contentType: "text/plain")
.WithTags("admin")
.WithName("GetAdminEvent")
@@ -148,6 +149,7 @@ public static RouteHandlerBuilder AddUpdateAdminEvent(this WebApplication app)
})
.Accepts<AdminEventDetails>(contentType: "application/json")
.Produces<AdminEventDetails>(statusCode: StatusCodes.Status200OK, contentType: "application/json")
.Produces(statusCode: StatusCodes.Status400BadRequest)
.Produces(statusCode: StatusCodes.Status401Unauthorized)
.Produces(statusCode: StatusCodes.Status404NotFound)
.Produces<string>(statusCode: StatusCodes.Status500InternalServerError, contentType: "text/plain")
Original file line number Diff line number Diff line change
@@ -56,7 +56,9 @@ public static RouteHandlerBuilder AddChatCompletions(this WebApplication app)
.Accepts<ChatCompletionOptions>(contentType: "application/json")
.Produces<ChatCompletion>(statusCode: StatusCodes.Status200OK, contentType: "application/json")
// TODO: Check both request/response payloads
.Produces(statusCode: StatusCodes.Status400BadRequest)
.Produces(statusCode: StatusCodes.Status401Unauthorized)
.Produces(statusCode: StatusCodes.Status404NotFound)
.Produces<string>(statusCode: StatusCodes.Status500InternalServerError, contentType: "text/plain")
.WithTags("openai")
.WithName("GetChatCompletions")

Unchanged files with check annotations Beta

public class AdminEventRepository : IAdminEventRepository
{
/// <inheritdoc />
public async Task<AdminEventDetails> CreateEvent(AdminEventDetails eventDetails)

Check warning on line 45 in src/AzureOpenAIProxy.ApiApp/Repositories/AdminEventRepository.cs

GitHub Actions / build-test

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 45 in src/AzureOpenAIProxy.ApiApp/Repositories/AdminEventRepository.cs

GitHub Actions / build-test

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
throw new NotImplementedException();
}
/// <inheritdoc />
public async Task<List<AdminEventDetails>> GetEvents()

Check warning on line 51 in src/AzureOpenAIProxy.ApiApp/Repositories/AdminEventRepository.cs

GitHub Actions / build-test

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 51 in src/AzureOpenAIProxy.ApiApp/Repositories/AdminEventRepository.cs

GitHub Actions / build-test

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
throw new NotImplementedException();
}
/// <inheritdoc />
public async Task<AdminEventDetails> GetEvent(Guid eventId)

Check warning on line 57 in src/AzureOpenAIProxy.ApiApp/Repositories/AdminEventRepository.cs

GitHub Actions / build-test

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 57 in src/AzureOpenAIProxy.ApiApp/Repositories/AdminEventRepository.cs

GitHub Actions / build-test

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
throw new NotImplementedException();
}
/// <inheritdoc />
public async Task<AdminEventDetails> UpdateEvent(Guid eventId, AdminEventDetails eventDetails)

Check warning on line 63 in src/AzureOpenAIProxy.ApiApp/Repositories/AdminEventRepository.cs

GitHub Actions / build-test

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 63 in src/AzureOpenAIProxy.ApiApp/Repositories/AdminEventRepository.cs

GitHub Actions / build-test

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
throw new NotImplementedException();
}