wy471x opened a new pull request, #6452:
URL: https://github.com/apache/shenyu/pull/6452

   Null-guard openapi.getServers() and operation.getParameters() to avoid
   NPE/IndexOutOfBoundsException when importing valid OpenAPI 3 documents
   that omit top-level servers or operation parameters.
   
   <!-- Describe your PR here; e.g. Fixes #issueNo -->
   
   <!--
   Thank you for proposing a pull request. This template will guide you through 
the essential steps necessary for a pull request.
   -->
   Make sure that:
   
   - [X] You have read the [contribution 
guidelines](https://shenyu.apache.org/community/contributor-guide).
   - [X] You submit test cases (unit or integration tests) that back your 
changes.
   - [X] Your local test passed `./mvnw clean install 
-Dmaven.javadoc.skip=true`.
   
   ## Summary of the changes: 
   ### SwaggerImportServiceImpl.java:                                           
    
     - Line 219: Added null/empty guard for openapi.getServers(), throwing a 
clear                  
     IllegalArgumentException instead of NPE/IOOBE when the OpenAPI document 
lacks a top-level      
     servers field. The importMcpConfig caller already catches 
IllegalArgumentException and surfaces
      it as HTTP 400.                                                           
                    
     - Line 234: Added null guard for operation.getParameters(), defaulting to 
an empty string ""
     for parameterTypes when an operation declares no parameters.               
                 
                                                                                
                    
    ### Unit tests (SwaggerImportServiceImplTest.java — 3 new tests):
     - buildMetaDataRegisterDTOShouldThrowWhenServersIsNull — verifies 
IllegalArgumentException when
      servers is null                                                           
                    
     - buildMetaDataRegisterDTOShouldThrowWhenServersIsEmpty — verifies 
IllegalArgumentException    
     when servers list is empty                                                 
                    
     - buildMetaDataRegisterDTOShouldHandleNullParameters — verifies 
parameterTypes is "" and       
     MetaDataRegisterDTO is built successfully when operation.parameters is null
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to