<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged parameter</title>
<link>https://coderlegion.com/tag/parameter</link>
<description>Powered by Question2Answer</description>
<item>
<title>Define the missing method. use &quot;this&quot; to distinguish the local member from the parameter name/ Poor</title>
<link>https://coderlegion.com/25714/define-the-missing-method-use-this-distinguish-the-local-member-from-parameter-name-poor</link>
<description>&lt;p&gt;The &lt;strong&gt;this&lt;/strong&gt; keyword in Java refers to the current object's instance.&lt;br&gt;
It is used to distinguish a local member (e.g. instance variable) from a method parameter with the same name.&lt;br&gt;
By prefixing &lt;strong&gt;this&lt;/strong&gt; to a member (instance variable or method), it can be accessed within the class.&lt;/p&gt;
&lt;h3 id=&quot;table-of-content-&quot;&gt;table of content:&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;what is &lt;strong&gt;this&lt;/strong&gt; keyword?  &lt;/li&gt;
&lt;li&gt;why &lt;strong&gt;this&lt;/strong&gt; keyword is used?&lt;/li&gt;
&lt;li&gt;how to use &lt;strong&gt;this&lt;/strong&gt; keyword?&lt;/li&gt;
&lt;li&gt;conclusion about &lt;strong&gt;this&lt;/strong&gt; keyword&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;what-is-this-keyword-&quot;&gt;what is &quot;this&quot; keyword?&lt;/h3&gt;
&lt;p&gt; &lt;strong&gt;this&lt;/strong&gt; is a predefined keyword in java.&lt;/p&gt;
&lt;h3 id=&quot;why-this-keyword-is-used-&quot;&gt;Why &quot;this&quot; keyword is used?&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;this&lt;/strong&gt; keyword is used for accessing the global/instance member of the class within same class.&lt;/p&gt;
&lt;h3 id=&quot;how-to-use-this-keyword-&quot;&gt;How to use &quot;this&quot; keyword?&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;this&lt;/strong&gt; keyword always used .(dot) like this.variableName of class.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;class Company{
   String name;
   
   public void setName(String name) {
      this.name = name;
   }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;code-briefing&quot;&gt;Code Briefing&lt;/h3&gt;
&lt;p&gt;Here, the method setName takes an argument name, which would have the same name as the instance variable name. By using this.name, we are able to distinguish the local member from the parameter name.&lt;/p&gt;
&lt;h3 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h3&gt;
&lt;p&gt; &lt;strong&gt;This&lt;/strong&gt; in Java refers to the current object's instance and is used to differentiate local members from &lt;br&gt;
  method parameters with the same name, allowing access to members within the class.&lt;/p&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/25714/define-the-missing-method-use-this-distinguish-the-local-member-from-parameter-name-poor</guid>
<pubDate>Fri, 28 Aug 2026 17:32:11 +0000</pubDate>
</item>
<item>
<title>Running OpenAPI Validation in GitHub Actions and Showing Findings in Pull Requests</title>
<link>https://coderlegion.com/21636/running-openapi-validation-in-github-actions-and-showing-findings-in-pull-requests</link>
<description>
&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href=&quot;https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;Star git-lrc on GitHub&lt;/a&gt; to help more developers discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;In a previous article, I explained what SARIF is and why many security and quality tools use it as a common reporting format.&lt;/p&gt;

&lt;p&gt;In this article, we'll focus on a practical example: validating an OpenAPI specification in GitHub Actions and displaying findings directly inside GitHub Pull Requests.&lt;/p&gt;

&lt;p&gt;By the end, you'll have a workflow that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lints your OpenAPI specification&lt;/li&gt;
&lt;li&gt;Generates a SARIF report&lt;/li&gt;
&lt;li&gt;Uploads results to GitHub Code Scanning&lt;/li&gt;
&lt;li&gt;Shows annotations directly in Pull Requests&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sample OpenAPI Specification
&lt;/h2&gt;

&lt;p&gt;Let's start with a simple OpenAPI file that contains a deliberate issue.&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight yaml&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;openapi&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;3.0.3&lt;/span&gt;

&lt;span class=&quot;na&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;User API&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;version&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;1.0.0&lt;/span&gt;

&lt;span class=&quot;na&quot;&gt;paths&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;s&quot;&gt;/users/{id}&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;operationId&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;getUserById&lt;/span&gt;

      &lt;span class=&quot;na&quot;&gt;parameters&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;userId&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;path&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;required&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;schema&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;string&lt;/span&gt;

      &lt;span class=&quot;na&quot;&gt;responses&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;200&quot;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;:&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;User found&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice that the path is:&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight plaintext&quot;&gt;&lt;code&gt;/users/{id}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;but the parameter is named:&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight plaintext&quot;&gt;&lt;code&gt;userId
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The parameter name should match the path placeholder (&lt;code&gt;id&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;We'll use this mistake to verify that our workflow correctly reports findings.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing Spectral
&lt;/h2&gt;

&lt;p&gt;For this example, we'll use Spectral, one of the most popular OpenAPI linting tools.&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight shell&quot;&gt;&lt;code&gt;npm &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-g&lt;/span&gt; @stoplight/spectral-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it locally:&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight shell&quot;&gt;&lt;code&gt;spectral lint openapi.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see an error related to the path parameter mismatch.&lt;/p&gt;

&lt;h2&gt;
  
  
  Generating a SARIF Report
&lt;/h2&gt;

&lt;p&gt;Instead of printing results to the console, we can generate a SARIF report:&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight shell&quot;&gt;&lt;code&gt;spectral lint openapi.yaml &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--format&lt;/span&gt; sarif &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--output&lt;/span&gt; results.sarif
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This produces:&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight plaintext&quot;&gt;&lt;code&gt;results.sarif
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;which GitHub can consume directly.&lt;/p&gt;

&lt;h2&gt;
  
  
  GitHub Actions Workflow
&lt;/h2&gt;

&lt;p&gt;Create:&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight plaintext&quot;&gt;&lt;code&gt;.github/workflows/openapi.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight yaml&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;OpenAPI Validation&lt;/span&gt;

&lt;span class=&quot;na&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;pull_request&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;

&lt;span class=&quot;na&quot;&gt;permissions&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;contents&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;read&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;security-events&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;write&lt;/span&gt;

&lt;span class=&quot;na&quot;&gt;jobs&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;openapi&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;runs-on&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ubuntu-latest&lt;/span&gt;

    &lt;span class=&quot;na&quot;&gt;steps&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;uses&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;actions/checkout@v4&lt;/span&gt;

      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;uses&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;actions/setup-node@v4&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;node-version&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;20&lt;/span&gt;

      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Install Spectral&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;npm install -g @stoplight/spectral-cli&lt;/span&gt;

      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Generate SARIF Report&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;pi&quot;&gt;|&lt;/span&gt;
          &lt;span class=&quot;s&quot;&gt;spectral lint openapi.yaml \&lt;/span&gt;
            &lt;span class=&quot;s&quot;&gt;--format sarif \&lt;/span&gt;
            &lt;span class=&quot;s&quot;&gt;--output results.sarif&lt;/span&gt;

      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Upload SARIF&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;uses&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;github/codeql-action/upload-sarif@v3&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;sarif_file&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;results.sarif&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How It Works
&lt;/h2&gt;

&lt;p&gt;The workflow performs four simple steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Checks out the repository&lt;/li&gt;
&lt;li&gt;Installs Spectral&lt;/li&gt;
&lt;li&gt;Generates a SARIF report&lt;/li&gt;
&lt;li&gt;Uploads the SARIF report to GitHub&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The upload step is handled by GitHub's official SARIF uploader:&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight yaml&quot;&gt;&lt;code&gt;&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;uses&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;github/codeql-action/upload-sarif@v3&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;sarif_file&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;results.sarif&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once uploaded, GitHub automatically processes the findings.&lt;/p&gt;

&lt;h2&gt;
  
  
  Viewing Results in Pull Requests
&lt;/h2&gt;

&lt;p&gt;After opening a Pull Request, GitHub analyzes the uploaded SARIF report and associates findings with the corresponding files and lines.&lt;/p&gt;

&lt;p&gt;For our example, GitHub highlights the parameter definition and reports something similar to:&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight plaintext&quot;&gt;&lt;code&gt;Path parameter &quot;id&quot; is not defined.
Expected parameter name &quot;id&quot; but found &quot;userId&quot;.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Developers can review the issue directly from the Pull Request without searching through GitHub Action logs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I Prefer This Approach
&lt;/h2&gt;

&lt;p&gt;Many teams fail OpenAPI validation jobs and require developers to inspect CI logs.&lt;/p&gt;

&lt;p&gt;While this works, it doesn't scale well when repositories contain multiple specifications or many validation rules.&lt;/p&gt;

&lt;p&gt;Uploading SARIF results provides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inline annotations&lt;/li&gt;
&lt;li&gt;Better visibility during code review&lt;/li&gt;
&lt;li&gt;Centralized findings in GitHub Code Scanning&lt;/li&gt;
&lt;li&gt;Consistent reporting across different tools&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The same workflow can later be extended to include security scanners, secret scanners, IaC scanners, and custom validation tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Integrating OpenAPI validation into GitHub Actions is straightforward. With Spectral generating SARIF output and GitHub handling the presentation layer, developers receive feedback exactly where they are already reviewing code: inside the Pull Request.&lt;/p&gt;

&lt;p&gt;If your organization already uses SARIF for other security or quality tools, OpenAPI validation can fit naturally into the same workflow with only a few lines of configuration.&lt;br&gt;
&lt;a href=&quot;https://github.com/HexmosTech/git-lrc&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;&lt;img src=&quot;https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnuphqwcp6bha9ol6pdo3.png&quot; alt=&quot;git-lrc&quot; width=&quot;360&quot; height=&quot;540&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It&amp;rsquo;s online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;&amp;#11088; &lt;a href=&quot;https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;Star git-lrc on GitHub&lt;/a&gt;&lt;/p&gt;
</description>
<category>Other</category>
<guid isPermaLink="true">https://coderlegion.com/21636/running-openapi-validation-in-github-actions-and-showing-findings-in-pull-requests</guid>
<pubDate>Sat, 04 Jul 2026 00:49:15 +0000</pubDate>
</item>
</channel>
</rss>