-
Notifications
You must be signed in to change notification settings - Fork 0
Extract shared contracts to common module and configure OpenAPI #9
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| rootProject.name = 'backend' | ||
| include 'smartjam-api' | ||
| include 'smartjam-analyzer' | ||
| include 'smartjam-analyzer' | ||
| include 'smartjam-common' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...tjam-api/src/main/java/com/smartjam/smartjamapi/infrastructure/openapi/OpenApiConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| package com.smartjam.smartjamapi.infrastructure.openapi; | ||
|
|
||
| import io.swagger.v3.oas.models.Components; | ||
| import io.swagger.v3.oas.models.OpenAPI; | ||
| import io.swagger.v3.oas.models.info.Contact; | ||
| import io.swagger.v3.oas.models.info.Info; | ||
| import io.swagger.v3.oas.models.security.SecurityRequirement; | ||
| import io.swagger.v3.oas.models.security.SecurityScheme; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
|
|
||
| /** | ||
| * Configuration for OpenAPI documentation using SpringDoc. Defines metadata, security schemes, and global requirements | ||
| * for the API. | ||
| */ | ||
| @Configuration | ||
| public class OpenApiConfig { | ||
|
|
||
| private static final String SECURITY_SCHEME_NAME = "bearerAuth"; | ||
| /** | ||
| * Customizes the OpenAPI definition. | ||
| * | ||
| * @return a fully configured OpenAPI object. | ||
| */ | ||
| @Bean | ||
| public OpenAPI customOpenAPI() { | ||
| return new OpenAPI() | ||
| .info(createApiInfo()) | ||
| .addSecurityItem(new SecurityRequirement().addList(SECURITY_SCHEME_NAME)) | ||
| .components(new Components().addSecuritySchemes(SECURITY_SCHEME_NAME, createSecurityScheme())); | ||
| } | ||
|
|
||
| private Info createApiInfo() { | ||
| return new Info() | ||
| .title("SmartJam API") | ||
| .version("1.0") | ||
| .description(""" | ||
| Interactive Music Learning and Performance Analysis System. | ||
|
|
||
| Development Team: | ||
| - Sanjar Satlykov ([satlykovs@gmail.com](mailto:satlykovs@gmail.com)) | ||
| - Anton Podrezov ([toni.podrezov@gmail.com](mailto:toni.podrezov@gmail.com)) | ||
| - Serj Baskov ([baskovs450@gmail.com](mailto:baskovs450@gmail.com)) | ||
|
|
||
| Supervised by: | ||
| - Andrey Sheremeev ([sheremeev.andrey@gmail.com](mailto:sheremeev.andrey@gmail.com)) | ||
| """) | ||
| .contact(new Contact() | ||
| .name("SmartJam Team") | ||
| .email("satlykovs@gmail.com") | ||
| .url("https://github.com/Satlykovs/SmartJam")); | ||
| } | ||
|
|
||
| private SecurityScheme createSecurityScheme() { | ||
| return new SecurityScheme() | ||
| .name(SECURITY_SCHEME_NAME) | ||
| .type(SecurityScheme.Type.HTTP) | ||
| .scheme("bearer") | ||
| .bearerFormat("JWT") | ||
| .description("Provide your JWT token obtained from the login endpoint."); | ||
| } | ||
| } | ||
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
|
|
||
| plugins { | ||
| id 'java-library' | ||
| } | ||
|
|
||
| bootJar { | ||
| enabled = false | ||
| } | ||
|
|
||
| jar { | ||
| enabled = true | ||
| } | ||
|
|
||
| dependencies { | ||
| api 'com.fasterxml.jackson.core:jackson-annotations' | ||
| api 'com.fasterxml.jackson.core:jackson-databind' | ||
| } | ||
|
|
||
| group = 'com.smartjam' | ||
| version = '0.0.1-SNAPSHOT' |
15 changes: 15 additions & 0 deletions
15
backend/smartjam-common/src/main/java/com/smartjam/common/dto/FeedbackEvent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.smartjam.common.dto; | ||
|
|
||
| import com.smartjam.common.model.FeedbackType; | ||
|
|
||
| /** | ||
| * A shared contract for a single feedback occurrence. Used by Analyzer to produce results and by API/Mobile to display | ||
| * them. | ||
| */ | ||
| public record FeedbackEvent( | ||
| double teacherStartTime, | ||
| double teacherEndTime, | ||
| double studentStartTime, | ||
| double studentEndTime, | ||
| FeedbackType type, | ||
| double severity) {} |
2 changes: 1 addition & 1 deletion
2
...jamanalyzer/api/kafka/dto/S3EventDto.java → ...om/smartjam/common/dto/s3/S3EventDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package com.smartjam.smartjamanalyzer.api.kafka.dto; | ||
| package com.smartjam.common.dto.s3; | ||
|
|
||
| import java.util.List; | ||
|
|
||
|
|
||
13 changes: 13 additions & 0 deletions
13
backend/smartjam-common/src/main/java/com/smartjam/common/model/AudioProcessingStatus.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package com.smartjam.common.model; | ||
|
|
||
| /** | ||
| * Represents the lifecycle stages of an audio processing task. Used to track the state from the moment a database | ||
| * record is created until the final analysis result is stored. | ||
| */ | ||
| public enum AudioProcessingStatus { | ||
| AWAITING_UPLOAD, | ||
| UPLOADED, | ||
| ANALYZING, | ||
| COMPLETED, | ||
| FAILED | ||
| } |
10 changes: 10 additions & 0 deletions
10
backend/smartjam-common/src/main/java/com/smartjam/common/model/FeedbackType.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.smartjam.common.model; | ||
|
|
||
| /** | ||
| * Categories of musical discrepancies identified during the comparison of a student's performance against the teacher's | ||
| * reference. | ||
| */ | ||
| public enum FeedbackType { | ||
| WRONG_NOTE, | ||
| WRONG_RHYTHM | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.