<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>Mohammed Sarfaraz — Applied AI Blog</title>
        <link>https://sarfaraz.io/blog</link>
        <description>Mohammed Sarfaraz — Applied AI Blog</description>
        <lastBuildDate>Fri, 01 May 2026 19:59:11 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <item>
            <title><![CDATA[DevSecOps Insights- Securing Your Web Applications]]></title>
            <link>https://sarfaraz.io/blog/devsecops-insights-securing-your-web-applications</link>
            <guid>devsecops-insights-securing-your-web-applications</guid>
            <pubDate>Fri, 01 May 2026 19:59:11 GMT</pubDate>
            <description><![CDATA[Securing Your Web Applications Banner]]></description>
            <content:encoded><![CDATA[<p><img loading="lazy" alt="Securing Your Web Applications Banner" src="/assets/images/banner_22-10-2024-securing-web-applications-owasp-top-10-vulnerabilities-d805bdebb795596e7f877d1f3d1ff8dc.webp" width="720" height="405" class="img_ev3q"></p><h1>DevSecOps Insights: Securing Your Web Applications</h1><p>As the web grows, so do the challenges of securing modern web applications, especially in dynamic environments like microservices. Unsecured configuration servers, weak authentication practices, and poor session management aren’t just risks — they can open doors to more complex attacks. The OWASP Top 10 offers a solid foundation, but for larger applications, developers and security teams often need to think beyond the basics to maintain a strong security posture. In this article, we’ll dive into key vulnerabilities such as input validation, data encoding, and session management with a focus on building secure web systems.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="1-input-validation-your-first-line-of-defense">1. Input Validation: Your First Line of Defense<a class="hash-link" href="#1-input-validation-your-first-line-of-defense" title="Direct link to heading">​</a></h2><p>Let’s start digging the trenches. You need to secure every step from start to finish if you want to build a secure system. This approach is known as Defense in Depth. To protect your web application from vulnerabilities, it’s crucial to validate all user input, ensuring only valid data is processed and preventing attacks like SQL injection and XSS.</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="explore-best-practices-for-input-validation">Explore Best Practices for Input Validation:<a class="hash-link" href="#explore-best-practices-for-input-validation" title="Direct link to heading">​</a></h3><ul><li><strong>Whitelist Inputs</strong>: Only allow inputs that meet predefined, acceptable criteria. For example, if an input field expects a date, restrict inputs to valid date formats only.</li><li><strong>Data Type Checks</strong>: Ensure the input matches the expected data type (e.g., integers for age fields, strings for names).</li><li><strong>Length Checks</strong>: Set limits on input lengths to avoid attacks like buffer overflows.</li></ul><p>By implementing robust input validation techniques, developers can minimize the risk of processing harmful data that could compromise the application.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="2-data-encoding-sanitize-inputs-to-prevent-injection-attacks">2. Data Encoding: Sanitize Inputs to Prevent Injection Attacks<a class="hash-link" href="#2-data-encoding-sanitize-inputs-to-prevent-injection-attacks" title="Direct link to heading">​</a></h2><p>The trenches are dug, now let’s check the supply lines. Encoding sanitizes user input to ensure it’s treated as data, not executable code, reducing the risk of injection attacks.</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="key-techniques">Key Techniques:<a class="hash-link" href="#key-techniques" title="Direct link to heading">​</a></h3><ul><li><strong>HTML Encoding</strong>: Convert special characters (e.g., <code>&lt;</code> to <code>&amp;lt;</code>) to prevent XSS.</li><li><strong>URL Encoding</strong>: Ensure URLs are safely encoded.</li><li><strong>JavaScript Encoding</strong>: JavaScript is the backbone of WebApps; however, you need to ensure that you encode inputs to avoid script injection.</li></ul><p>Consistent encoding and sanitization across all inputs protect applications from malicious attacks.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="3-authentication-and-password-management-protecting-user-identities">3. Authentication and Password Management: Protecting User Identities<a class="hash-link" href="#3-authentication-and-password-management-protecting-user-identities" title="Direct link to heading">​</a></h2><p>Let’s review the defense lines. Authentication confirms user identities, while password management ensures passwords are securely stored. Weak authentication or sloppy password practices can open doors to unauthorized access and data breaches.</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="best-practices-for-strong-authentication">Best Practices for Strong Authentication:<a class="hash-link" href="#best-practices-for-strong-authentication" title="Direct link to heading">​</a></h3><ul><li><strong>Enforce Strong Password Policies</strong>: Require complex passwords with a mix of characters.</li><li><strong>Use Multi-Factor Authentication (MFA)</strong>: Implement MFA, preferably app-based or hardware tokens, for added security.</li><li><strong>Secure Password Storage</strong>: Use salted hashing (e.g., bcrypt) to store passwords securely, not plain encryption.</li></ul><p>By following these practices, organizations can better protect sensitive data and prevent unauthorized access to their systems.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="4-session-management-keeping-user-sessions-secure">4. Session Management: Keeping User Sessions Secure<a class="hash-link" href="#4-session-management-keeping-user-sessions-secure" title="Direct link to heading">​</a></h2><p>Let’s secure the command post. In the stateless world of web applications, sessions are key. Session management is crucial for maintaining secure user interactions. Poor session management can lead to serious threats like session hijacking or session fixation attacks.</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="key-considerations-for-secure-session-management">Key Considerations for Secure Session Management:<a class="hash-link" href="#key-considerations-for-secure-session-management" title="Direct link to heading">​</a></h3><ul><li><strong>Secure Cookies</strong>: Use HttpOnly and Secure flags to protect session cookies.</li><li><strong>Session Timeouts</strong>: Auto-terminate sessions after inactivity.</li><li><strong>Regenerate IDs</strong>: Refresh session IDs on successful login.</li></ul><p>Effective session management helps ensure that users remain authenticated securely and that their session data is protected.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="5-error-handling-and-logging-healthy-learning">5. Error Handling and Logging: Healthy Learning<a class="hash-link" href="#5-error-handling-and-logging-healthy-learning" title="Direct link to heading">​</a></h2><p>Let’s maintain a clear line of sight on the battlefield. Error handling and logging are crucial for situational awareness in the threat theater. Log what’s essential — fewer distractions mean sharper focus on real threats. Proper error management prevents sensitive data leaks, and efficient logging helps detect and resolve issues swiftly. Building resilient systems ensures long-term operational security, saving resources and protecting your firm’s reputation.</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="effective-strategies-for-error-handling">Effective Strategies for Error Handling:<a class="hash-link" href="#effective-strategies-for-error-handling" title="Direct link to heading">​</a></h3><ul><li><strong>Display User-Friendly Error Messages</strong>: Provide generic error messages to users, while logging detailed information internally to avoid revealing sensitive data.</li><li><strong>Consistent Logging</strong>: Keep logs of critical events, such as failed login attempts and system errors, to aid in security audits. These meaningful logs can be used in IDS and IPS systems.</li><li><strong>Monitor Logs for Anomalies</strong>: Regularly review logs for unusual activity, which can help detect potential security breaches early. You can feed this data into IDS and SIEM systems to enhance cybersecurity.</li></ul><p>By implementing robust error handling and logging practices, organizations can improve their ability to detect and respond to security incidents.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="conclusion">Conclusion<a class="hash-link" href="#conclusion" title="Direct link to heading">​</a></h2><p>Securing systems is an ongoing process that requires discipline. Addressing the OWASP Top 10 is key to building secure web applications. By focusing on input validation, data encoding, authentication, session management, and error handling, developers can reduce security risks. In today’s evolving threat landscape, these practices aren’t optional — they’re essential.</p><p>Stay ahead of evolving cyber threats by prioritizing the OWASP Top 10 to build secure applications. It’s not a silver bullet, but it’s definitely a good one to have.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="references">References<a class="hash-link" href="#references" title="Direct link to heading">​</a></h2><p>OWASP Foundation. (n.d.). OWASP. Retrieved from <a href="https://owasp.org/" target="_blank" rel="noopener noreferrer">https://owasp.org/</a></p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="tags">Tags<a class="hash-link" href="#tags" title="Direct link to heading">​</a></h2><p>#OWASPTop10 #WebApplicationSecurity #InputValidation #DataEncoding #Authentication #SessionManagement #ErrorHandling #Cybersecurity #XSSPrevention #SQLInjection #SecureDevelopment #PasswordManagement #MultiFactorAuthentication #SessionHijacking #WebDevelopment #SecurityBestPractices #SoftwareSecurity #LoggingAndMonitoring #ThreatMitigation #VulnerabilityManagement</p>]]></content:encoded>
            <category>OWASPTop10</category>
            <category>WebApplicationSecurity</category>
            <category>InputValidation</category>
            <category>DataEncoding</category>
            <category>Authentication</category>
            <category>SessionManagement</category>
            <category>ErrorHandling</category>
            <category>Cybersecurity</category>
            <category>XSSPrevention</category>
            <category>SQLInjection</category>
            <category>SecureDevelopment</category>
            <category>PasswordManagement</category>
            <category>MultiFactorAuthentication</category>
            <category>SessionHijacking</category>
            <category>WebDevelopment</category>
            <category>SecurityBestPractices</category>
            <category>SoftwareSecurity</category>
            <category>LoggingAndMonitoring</category>
            <category>ThreatMitigation</category>
            <category>VulnerabilityManagement</category>
        </item>
        <item>
            <title><![CDATA[Spring Boot 3- Easy Swagger Integration for REST API Documentation]]></title>
            <link>https://sarfaraz.io/blog/spring-boot-swagger-integration</link>
            <guid>spring-boot-swagger-integration</guid>
            <pubDate>Fri, 18 Oct 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[Do you want to know what's in a REST API without having to ask? Ask no more! Swagger is here to help, and it is an effective tool for describing RESTful APIs. In this article, I will provide a simple implementation that you can use in your Spring Boot application to make it more effective. I’m writing this article because I struggled to find a straightforward method that effectively communicates the implementation details.]]></description>
            <content:encoded><![CDATA[<p>Do you want to know what's in a REST API without having to ask? Ask no more! Swagger is here to help, and it is an effective tool for describing RESTful APIs. In this article, I will provide a simple implementation that you can use in your Spring Boot application to make it more effective. I’m writing this article because I struggled to find a straightforward method that effectively communicates the implementation details.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="github-repository-example">GitHub Repository Example<a class="hash-link" href="#github-repository-example" title="Direct link to heading">​</a></h2><p>For a practical example, check out the GitHub repository: <strong>Spring Boot 3 OpenAPI Swagger Example</strong>.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="what-we-will-build">What We Will Build<a class="hash-link" href="#what-we-will-build" title="Direct link to heading">​</a></h2><p>We'll build a simple <strong>Products REST API</strong> that sources data from a service class. You can easily extend this to use your own data source. The focus will be on integrating Swagger to document the API endpoints.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="getting-started">Getting Started<a class="hash-link" href="#getting-started" title="Direct link to heading">​</a></h2><p>You can generate a standard Spring Boot application using <strong>Spring Initializr</strong>. Alternatively, start with the pre-configured Git repository mentioned above.</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="step-1-of-3-dependencies">Step 1 of 3: Dependencies<a class="hash-link" href="#step-1-of-3-dependencies" title="Direct link to heading">​</a></h3><p>Add the following dependency to your <code>pom.xml</code>:</p><div class="language-xml codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-xml codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;</span><span class="token tag" style="color:rgb(255, 121, 198)">properties</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">  </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;</span><span class="token tag" style="color:rgb(255, 121, 198)">springdoc.version</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain">2.1.0</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;/</span><span class="token tag" style="color:rgb(255, 121, 198)">springdoc.version</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;/</span><span class="token tag" style="color:rgb(255, 121, 198)">properties</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;</span><span class="token tag" style="color:rgb(255, 121, 198)">dependencies</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">  </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;</span><span class="token tag" style="color:rgb(255, 121, 198)">dependency</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;</span><span class="token tag" style="color:rgb(255, 121, 198)">groupId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain">org.springdoc</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;/</span><span class="token tag" style="color:rgb(255, 121, 198)">groupId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;</span><span class="token tag" style="color:rgb(255, 121, 198)">artifactId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain">springdoc-openapi-starter-webmvc-ui</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;/</span><span class="token tag" style="color:rgb(255, 121, 198)">artifactId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;</span><span class="token tag" style="color:rgb(255, 121, 198)">version</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain">${springdoc.version}</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;/</span><span class="token tag" style="color:rgb(255, 121, 198)">version</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">  </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;/</span><span class="token tag" style="color:rgb(255, 121, 198)">dependency</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;/</span><span class="token tag" style="color:rgb(255, 121, 198)">dependencies</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><h3 class="anchor anchorWithStickyNavbar_LWe7" id="step-2-of-3-configuration">Step 2 of 3: Configuration<a class="hash-link" href="#step-2-of-3-configuration" title="Direct link to heading">​</a></h3><p>Update your application.properties:</p><div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token plain"># SpringDoc Configuration</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">springdoc.api-docs.enabled=true</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">springdoc.swagger-ui.path=/swagger-ui.html</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">springdoc.swagger-ui.try-it-out-enabled=true</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"># Server Configuration</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">server.port=8088</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">server.servlet.context-path=/api</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><h3 class="anchor anchorWithStickyNavbar_LWe7" id="optional-swagger-configuration-swaggerconfigjava">Optional Swagger Configuration (SwaggerConfig.java)<a class="hash-link" href="#optional-swagger-configuration-swaggerconfigjava" title="Direct link to heading">​</a></h3><p>To customize your Swagger documentation, use this configuration:</p><div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token plain">package com.springboot.example.docs.config;</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">import org.springframework.context.annotation.Bean;</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">import org.springframework.context.annotation.Configuration;</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">import io.swagger.v3.oas.models.OpenAPI;</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">import io.swagger.v3.oas.models.info.Info;</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">import io.swagger.v3.oas.models.info.Contact;</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">import io.swagger.v3.oas.models.info.License;</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">import io.swagger.v3.oas.models.servers.Server;</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">@Configuration</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">public class SwaggerConfig {</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    @Bean</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    public OpenAPI customOpenAPI(@Value("${server.port}") String serverPort,</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                                 @Value("${server.servlet.context-path}") String contextPath) {</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">        Info info = new Info()</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">            .title("Products API")</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">            .version("1.0.0")</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">            .description("API documentation for managing products.")</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">            .termsOfService("http://swagger.io/terms/")</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">            .contact(new Contact()</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                .name("DevSecOps Team")</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                .url("http://devsecops.com/contact")</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                .email("support@devsecops.com"))</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">            .license(new License()</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                .name("Apache 2.0")</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                .url("http://www.apache.org/licenses/LICENSE-2.0.html"));</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">        Server server = new Server()</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">            .url(String.format("http://localhost:%s%s", serverPort, contextPath))</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">            .description("Development Server");</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">        return new OpenAPI().info(info).addServersItem(server);</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    }</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><h3 class="anchor anchorWithStickyNavbar_LWe7" id="step-3-of-3-creating-your-rest-api">Step 3 of 3: Creating Your REST API<a class="hash-link" href="#step-3-of-3-creating-your-rest-api" title="Direct link to heading">​</a></h3><p>Here's a basic ProductsController to demonstrate API documentation with Swagger:</p><div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token plain">@RestController</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">@RequestMapping("/products")</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">public class ProductsController {</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    private final ProductService productService;</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    public ProductsController(ProductService productService) {</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">        this.productService = productService;</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    }</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    @Operation(summary = "Get all products")</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    @ApiResponses(value = {</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">        @ApiResponse(responseCode = "200", description = "Successfully retrieved list of products"),</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">        @ApiResponse(responseCode = "500", description = "Internal server error")</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    })</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    @GetMapping</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    public ResponseEntity&lt;List&lt;Product&gt;&gt; getAllProducts() {</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">        return new ResponseEntity&lt;&gt;(productService.getAllProducts(), HttpStatus.OK);</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    }</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    // Other CRUD operations follow similar patterns...</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><h3 class="anchor anchorWithStickyNavbar_LWe7" id="good-to-go-launching-the-swagger-ui">Good to Go: Launching the Swagger UI<a class="hash-link" href="#good-to-go-launching-the-swagger-ui" title="Direct link to heading">​</a></h3><p>Run your application and open your browser to:</p><div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token plain">http://localhost:8088/api/swagger-ui/index.html</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>to see the Swagger documentation in action.</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="conclusion">Conclusion<a class="hash-link" href="#conclusion" title="Direct link to heading">​</a></h3><p>By integrating Swagger with Spring Boot 3, you've made your REST API more accessible, understandable, and easier to test. This setup provides a quick way to onboard team members and stakeholders with a comprehensive API view.</p><p>Stay tuned for the next article, where we'll dive deeper into building a CRUD REST API with Spring Boot 3 and JPA!</p>]]></content:encoded>
            <category>Spring Boot</category>
            <category>Swagger</category>
            <category>REST API</category>
            <category>Java</category>
        </item>
        <item>
            <title><![CDATA[Mastering ChatGPT with Prompt Engineering]]></title>
            <link>https://sarfaraz.io/blog/mastering-chatgpt-with-prompt-engineering</link>
            <guid>mastering-chatgpt-with-prompt-engineering</guid>
            <pubDate>Thu, 17 Oct 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[In the world of AI, if you are wondering how to get value out of it, then the answer is prompt engineering. The secret to maximizing the potential of language models like ChatGPT lies in prompt engineering. The skill of creating precise questions or instructions, or prompts, is what directs the AI to provide more accurate and contextually relevant responses. In simple terms, it's about asking accurate questions to get the right answers.]]></description>
            <content:encoded><![CDATA[<p>In the world of AI, if you are wondering how to get value out of it, then the answer is <strong>prompt engineering</strong>. The secret to maximizing the potential of language models like ChatGPT lies in prompt engineering. The skill of creating precise questions or instructions, or prompts, is what directs the AI to provide more accurate and contextually relevant responses. In simple terms, it's about asking accurate questions to get the right answers.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="what-is-a-prompt">What is a Prompt?<a class="hash-link" href="#what-is-a-prompt" title="Direct link to heading">​</a></h2><p>A <strong>prompt</strong> is the input or instruction you give to an AI model like ChatGPT to generate a response. It can be a question, a command, or any text that guides the model to provide a relevant answer or complete a task.</p><p>For example, if you ask, “Explain the importance of cybersecurity in 100 words,” the entire sentence acts as a prompt. The AI uses this input to generate a response based on its training.</p><p>In prompt engineering, crafting a well-structured prompt helps you get more accurate, specific, and useful answers from the AI. The quality of the output often depends on the clarity and detail of the prompt provided.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="what-is-the-engineering-in-prompt-engineering">What is the Engineering in “Prompt Engineering”?<a class="hash-link" href="#what-is-the-engineering-in-prompt-engineering" title="Direct link to heading">​</a></h2><p>In the context of prompt engineering, <strong>“engineering”</strong> refers to the strategic and structured approach of designing, testing, and refining prompts to achieve optimal responses from AI models like ChatGPT. In simple terms, it’s planning before asking what to ask. For instance, if you were to ask your colleague or your boss a question, you would carefully choose your words to get a meaningful response.</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="example">Example:<a class="hash-link" href="#example" title="Direct link to heading">​</a></h3><ul><li><strong>Basic Prompt</strong>: “Tell me about DevOps.”</li><li><strong>Engineered Prompt</strong>: “Explain the benefits of implementing DevOps in large-scale organizations, focusing on automation and collaboration.”</li></ul><h2 class="anchor anchorWithStickyNavbar_LWe7" id="why-does-prompt-engineering-matter">Why Does Prompt Engineering Matter?<a class="hash-link" href="#why-does-prompt-engineering-matter" title="Direct link to heading">​</a></h2><p>The accuracy and clarity of the prompts given have a significant impact on ChatGPT’s responses. Unclear or badly written prompts can lead to generic or unrelated responses. By refining prompts, users can tailor ChatGPT’s output to precisely meet their needs, making it a powerful tool for tasks such as content creation, idea generation, technical support, and even code debugging.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="tips-for-better-prompts-5-top-tips">Tips for Better Prompts: 5 Top Tips<a class="hash-link" href="#tips-for-better-prompts-5-top-tips" title="Direct link to heading">​</a></h2><ol><li><p><strong>Be Specific</strong>: Clarity is key. Avoid vague prompts. Your communication with ChatGPT will be more successful if it is clear and detailed. Instead of “Explain DevOps,” try “Describe the main tools used in DevOps for continuous integration and deployment.”</p></li><li><p><strong>Provide Context</strong>: Adding context helps ChatGPT define the scope and prepare the answer. For example, “I’m preparing a presentation for senior managers on cloud security. Can you summarize the top three challenges?” These context words shape how the AI interprets the prompt, guiding it to generate a response aligned with the purpose, audience, and topic.</p></li><li><p><strong>Ask Follow-Up Questions</strong>: No prompt is perfect. If the response isn’t ideal, ask a follow-up question or rephrase it. ChatGPT can refine its response based on your adjustments.</p></li><li><p><strong>Use Constraints or Formats</strong>: If you need answers in a specific format (like bullet points or a list), state that in the prompt. For example, “Summarize the benefits of DevSecOps in 3 bullet points.”</p></li><li><p><strong>Test and Iterate</strong>: Keep experimenting with different phrasings or angles. What might not work in one prompt could lead to excellent results with a slight tweak.</p></li></ol><h2 class="anchor anchorWithStickyNavbar_LWe7" id="conclusion">Conclusion:<a class="hash-link" href="#conclusion" title="Direct link to heading">​</a></h2><p>To get the most out of ChatGPT, effective prompt engineering is essential. By being specific, providing context, asking follow-up questions, utilizing structured formats, and experimenting, you can transform ChatGPT into a versatile tool that delivers exactly what you need. With practice, you’ll become an expert prompter and use AI more efficiently for various tasks. Lastly, remember that ChatGPT (or any other AI) is neither perfect nor 100% accurate, so always exercise caution when using its responses.</p><hr><p><strong>#PromptEngineering #AI #ChatGPT #MachineLearning #AIEducation</strong></p>]]></content:encoded>
            <category>Mastering ChatGPT</category>
            <category>AI</category>
            <category>Prompt Engineering</category>
            <category>ChatGPT</category>
        </item>
    </channel>
</rss>