Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/main-ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
EOF

echo "${{ secrets.APPLICATION_PROD_YML }}" > ./src/main/resources/application-prod.yml
echo "${{ secrets.APPLICATION_OAUTH2_DEV_YML }}" > ./src/main/resources/application-oauth2-dev.yml
echo "${{ secrets.APPLICATION_OAUTH2_PROD_YML }}" > ./src/main/resources/application-oauth2-prod.yml

mkdir -p src/test/resources
echo "${{ secrets.APPLICATION_TEST_YML }}" > ./src/test/resources/application-test.yml
Expand Down
8 changes: 5 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ services:
container_name: pinhouse-app
ports:
- "8080:8080"
env_file:
- .env # μ—¬κΈ°μ„œ .env νŒŒμΌμ„ 읽어 ν™˜κ²½ λ³€μˆ˜λ‘œ μ£Όμž…
volumes:
# μ„œλ²„μ˜ μ„€μ •νŒŒμΌ 폴더λ₯Ό μ»¨ν…Œμ΄λ„ˆ λ‚΄λΆ€λ‘œ μ—°κ²°
- /home/ubuntu/app/config:/app/config
environment:
- SPRING_PROFILES_ACTIVE=prod
# Springμ—κ²Œ μ™ΈλΆ€ νŒŒμΌμ„ 읽으라고 λͺ…λ Ή (이게 ν•΅μ‹¬μž…λ‹ˆλ‹€)
- SPRING_CONFIG_LOCATION=optional:classpath:/,file:/app/config/application-prod.yml,file:/app/config/application-oauth2-prod.yml
networks:
- backend-bridge

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.pinHouse.server.core.config.swaagger;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟑 Minor

νŒ¨ν‚€μ§€λͺ…에 μ˜€νƒ€κ°€ μžˆμŠ΅λ‹ˆλ‹€.

swaaggerκ°€ μ•„λ‹Œ swaggerκ°€ μ˜¬λ°”λ₯Έ μ² μžμž…λ‹ˆλ‹€.

πŸ› μˆ˜μ • μ œμ•ˆ
-package com.pinHouse.server.core.config.swaagger;
+package com.pinHouse.server.core.config.swagger;

디렉토리λͺ…도 ν•¨κ»˜ μˆ˜μ •ν•΄μ•Ό ν•©λ‹ˆλ‹€.

πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
package com.pinHouse.server.core.config.swaagger;
package com.pinHouse.server.core.config.swagger;
πŸ€– Prompt for AI Agents
In
`@src/main/java/com/pinHouse/server/core/config/swaagger/ProdSwaggerConfig.java`
at line 1, νŒ¨ν‚€μ§€ 선언에 μ˜€νƒ€κ°€ μžˆμ–΄ ProdSwaggerConfig 클래슀의 package ꡬ문을 "package
com.pinHouse.server.core.config.swaagger;"μ—μ„œ "package
com.pinHouse.server.core.config.swagger;"둜 λ³€κ²½ν•˜κ³ , μ†ŒμŠ€ 파일이 μœ„μΉ˜ν•œ 디렉토리 이름도 swaagger β†’
swagger둜 λ¦¬λ„€μž„ν•˜μ—¬ νŒ¨ν‚€μ§€ κ²½λ‘œμ™€ μ‹€μ œ 디렉토리가 μΌμΉ˜ν•˜λ„λ‘ μˆ˜μ •ν•˜μ„Έμš”.


import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.servers.Server;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.media.Schema;
import org.springdoc.core.customizers.OpenApiCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

import java.util.Map;
import java.util.TreeMap;

/**
* Swagger / OpenAPI μ„€μ • 클래슀
* - HTTPS μ„€μ •μœΌλ‘œ 인해 @OpenAPIDefinition μΆ”κ°€
* - μŠ€μ›¨κ±° λ‚΄λΆ€ JWT μ„€μ • μΆ”κ°€
*/

@Configuration
@Profile("prod")
@OpenAPIDefinition(servers = {@Server(url = "https://api.pinhouse.co.kr", description = "PinHouse 운영 μ„œλ²„")})
public class ProdSwaggerConfig {

@Bean
public OpenAPI openAPI() {
return new OpenAPI()
.info(apiInfo());
}


private Info apiInfo() {
return new Info()
.title("PinHouse Swagger")
.description("ν•€ν•˜μš°μŠ€ μŠ€μ›¨κ±°μž…λ‹ˆλ‹€.")
.version("1.0.0");
}

/// μŠ€ν‚€λ§ˆ 이름 κΈ°μ€€ μ˜€λ¦„μ°¨μˆœ
@Bean
public OpenApiCustomizer sortSchemasAlphabetically() {
return openApi -> {
Map<String, Schema> schemas = openApi.getComponents().getSchemas();
openApi.getComponents().setSchemas(new TreeMap<>(schemas));
};
}
Comment on lines +43 to +48
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

getSchemas()κ°€ null을 λ°˜ν™˜ν•  경우 NPEκ°€ λ°œμƒν•  수 μžˆμŠ΅λ‹ˆλ‹€.

OpenAPI μŠ€νŽ™μ— μŠ€ν‚€λ§ˆκ°€ μ—†λŠ” 경우 getSchemas()κ°€ null을 λ°˜ν™˜ν•  수 μžˆμ–΄ TreeMap 생성 μ‹œ NullPointerException이 λ°œμƒν•©λ‹ˆλ‹€.

πŸ› null 체크 μΆ”κ°€ μ œμ•ˆ
    `@Bean`
    public OpenApiCustomizer sortSchemasAlphabetically() {
        return openApi -> {
-            Map<String, Schema> schemas = openApi.getComponents().getSchemas();
-            openApi.getComponents().setSchemas(new TreeMap<>(schemas));
+            if (openApi.getComponents() != null && openApi.getComponents().getSchemas() != null) {
+                Map<String, Schema> schemas = openApi.getComponents().getSchemas();
+                openApi.getComponents().setSchemas(new TreeMap<>(schemas));
+            }
        };
    }
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public OpenApiCustomizer sortSchemasAlphabetically() {
return openApi -> {
Map<String, Schema> schemas = openApi.getComponents().getSchemas();
openApi.getComponents().setSchemas(new TreeMap<>(schemas));
};
}
public OpenApiCustomizer sortSchemasAlphabetically() {
return openApi -> {
if (openApi.getComponents() != null && openApi.getComponents().getSchemas() != null) {
Map<String, Schema> schemas = openApi.getComponents().getSchemas();
openApi.getComponents().setSchemas(new TreeMap<>(schemas));
}
};
}
πŸ€– Prompt for AI Agents
In
`@src/main/java/com/pinHouse/server/core/config/swaagger/ProdSwaggerConfig.java`
around lines 43 - 48, The sortSchemasAlphabetically() OpenApiCustomizer can NPE
if openApi.getComponents() or openApi.getComponents().getSchemas() is null;
update the method to null-check components and schemas (in
sortSchemasAlphabetically) before creating a TreeMap and only replace schemas
when non-null, or set an empty map when schemas are null, using the existing
openApi.getComponents() and getSchemas() accessors to locate and guard the
calls.

}
Loading