<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Swagger &#8211; Pauls Blog</title>
	<atom:link href="https://sterl.org/tag/swagger/feed/" rel="self" type="application/rss+xml" />
	<link>https://sterl.org</link>
	<description></description>
	<lastBuildDate>Fri, 06 Oct 2023 19:19:58 +0000</lastBuildDate>
	<language>de</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>
	<item>
		<title>Useful links for Event Driven Architectures</title>
		<link>https://sterl.org/2023/10/useful-links-for-event-driven-architectures/</link>
					<comments>https://sterl.org/2023/10/useful-links-for-event-driven-architectures/#comments</comments>
		
		<dc:creator><![CDATA[Paul Sterl]]></dc:creator>
		<pubDate>Thu, 05 Oct 2023 09:29:20 +0000</pubDate>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[asyncapi]]></category>
		<category><![CDATA[cloudevents]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[Event Driven]]></category>
		<category><![CDATA[eventcatalog]]></category>
		<category><![CDATA[OpenAPI]]></category>
		<category><![CDATA[Swagger]]></category>
		<guid isPermaLink="false">https://sterl.org/?p=965</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[
<ul class="wp-block-list">
<li><a href="https://cloudevents.io/">https://cloudevents.io/</a></li>



<li><a href="https://www.eventcatalog.dev/">https://www.eventcatalog.dev/</a></li>



<li><a href="https://www.asyncapi.com/">https://www.asyncapi.com/</a></li>



<li><a href="https://github.com/confluentinc/schema-registry">https://github.com/confluentinc/schema-registry</a></li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://sterl.org/2023/10/useful-links-for-event-driven-architectures/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Spring Boot Redirect to SwaggerUI</title>
		<link>https://sterl.org/2021/05/spring-boot-redirect-to-swaggerui/</link>
					<comments>https://sterl.org/2021/05/spring-boot-redirect-to-swaggerui/#respond</comments>
		
		<dc:creator><![CDATA[Paul Sterl]]></dc:creator>
		<pubDate>Fri, 21 May 2021 13:13:33 +0000</pubDate>
				<category><![CDATA[Spring Boot]]></category>
		<category><![CDATA[OpenAPI]]></category>
		<category><![CDATA[Swagger]]></category>
		<category><![CDATA[swagger-ui]]></category>
		<guid isPermaLink="false">https://sterl.org/?p=650</guid>

					<description><![CDATA[Problem Some services don&#8217;t have an UI and the OpenAPI/ Swagger UI should be used as default UI of the service. As so the root should be redirected directly to the SwaggerUI. Solution Just add a WebMvc redirect. Swagger Open API dependencies Spring Boot 2.x Ensure you check the current version: Spring Boot 3.x Ensure&#8230;]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Problem</h2>



<p>Some services don&#8217;t have an UI and the OpenAPI/ Swagger UI should be used as default UI of the service. As so the root should be redirected directly to the SwaggerUI.</p>



<h2 class="wp-block-heading">Solution</h2>



<p>Just add a WebMvc redirect.</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text/x-java&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Java&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;java&quot;}">@Configuration
public class OpenApiConfig implements WebMvcConfigurer {
  @Override
  public void addViewControllers(final ViewControllerRegistry registry) {
    registry.addRedirectViewController(&quot;/&quot;, &quot;/swagger-ui.html&quot;);
    // use setStatusCode(HttpStatus.XYZ) for any custom status code if required, e.g. MOVED_PERMANENTLY
    registry.addRedirectViewController(&quot;/swagger-ui&quot;, &quot;/swagger-ui.html&quot;);
    // any other alias
  }
}</pre></div>



<h3 class="wp-block-heading">Swagger Open API dependencies</h3>



<h4 class="wp-block-heading">Spring Boot 2.x</h4>



<p>Ensure you <a href="https://central.sonatype.com/search?q=springdoc-openapi-ui&amp;namespace=org.springdoc" target="_blank" rel="noreferrer noopener">check the current version</a>: </p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;xml&quot;,&quot;mime&quot;:&quot;application/xml&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;XML&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;xml&quot;}">        &lt;dependency&gt;
            &lt;groupId&gt;org.springdoc&lt;/groupId&gt;
            &lt;artifactId&gt;springdoc-openapi-ui&lt;/artifactId&gt;
            &lt;version&gt;1.7.0&lt;/version&gt;
        &lt;/dependency&gt;
       &lt;!-- if spring security is used --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.springdoc&lt;/groupId&gt;
            &lt;artifactId&gt;springdoc-openapi-security&lt;/artifactId&gt;
            &lt;version&gt;1.7.0&lt;/version&gt;
        &lt;/dependency&gt;</pre></div>



<h4 class="wp-block-heading">Spring Boot 3.x</h4>



<p>Ensure you <a href="https://central.sonatype.com/search?q=springdoc-openapi-starter-webmvc-ui&amp;namespace=org.springdoc" target="_blank" rel="noreferrer noopener">check the current version</a>:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;xml&quot;,&quot;mime&quot;:&quot;application/xml&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;XML&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;xml&quot;}">        &lt;dependency&gt;
            &lt;groupId&gt;org.springdoc&lt;/groupId&gt;
            &lt;artifactId&gt;springdoc-openapi-starter-webmvc-ui&lt;/artifactId&gt;
            &lt;version&gt;2.1.0&lt;/version&gt;
        &lt;/dependency&gt;</pre></div>



<p>With the new version you can also use the <code>application.yml</code> to configure the root directory as swagger ui:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;yaml&quot;,&quot;mime&quot;:&quot;text/x-yaml&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;YAML&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;yaml&quot;}">springdoc:
  swagger-ui:
    use-root-path: true</pre></div>



<h2 class="wp-block-heading">Links</h2>



<ul class="wp-block-list">
<li><a rel="noreferrer noopener" href="https://springdoc.org/" target="_blank">https://springdoc.org/</a></li>



<li><a href="https://springdoc.org/v2/">https://springdoc.org/v2/</a></li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://sterl.org/2021/05/spring-boot-redirect-to-swaggerui/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Spring Boot RestTemplate no SSL check</title>
		<link>https://sterl.org/2019/06/spring-boot-resttemplate-no-ssl-check/</link>
					<comments>https://sterl.org/2019/06/spring-boot-resttemplate-no-ssl-check/#respond</comments>
		
		<dc:creator><![CDATA[Paul Sterl]]></dc:creator>
		<pubDate>Sun, 16 Jun 2019 18:56:00 +0000</pubDate>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Spring Boot]]></category>
		<category><![CDATA[CodeGen]]></category>
		<category><![CDATA[HTTPS]]></category>
		<category><![CDATA[skip ssl]]></category>
		<category><![CDATA[SSL]]></category>
		<category><![CDATA[Swagger]]></category>
		<guid isPermaLink="false">https://sterl.org/?p=662</guid>

					<description><![CDATA[Problem By default the Spring RestTempalte and the swagger OpenAPI client does an SSL check. This is usually not required on the test system, as so the goal is to remove the SSL check from the Spring Boot Rest Template. RestTemplate Apache HTTP Client pom.xml Swagger OpenAPI Client Furthermore sometimes it is required to remove&#8230;]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Problem</h2>



<p>By default the Spring RestTempalte and the swagger OpenAPI client does an SSL check. This is usually not required on the test system, as so the goal is to remove the SSL check from the Spring Boot Rest Template.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
Remote host closed connection during handshake; nested exception is javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
</pre></div>


<h2 class="wp-block-heading">RestTemplate</h2>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text/x-java&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Java&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;java&quot;}">@Bean
public RestTemplate restTemplate() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException {
    final RestTemplate restTemplate = new RestTemplate(sslFactory());
    return restTemplate;
}

@Bean
public HttpComponentsClientHttpRequestFactory sslFactory() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException {
    final TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -&gt; true;

    final SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom()
                    .loadTrustMaterial(null, acceptingTrustStrategy)
                    .build();

    final SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext);

    final CloseableHttpClient httpClient = HttpClients.custom()
                    .setMaxConnPerRoute(250)
                    .setMaxConnTotal(250)
                    .setSSLSocketFactory(csf)
                    // during the SSL check we have also the verification of the host name,
                    // this can be skipped to like this:
                    .setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
                    .build();

    final HttpComponentsClientHttpRequestFactory requestFactory =
                    new HttpComponentsClientHttpRequestFactory();

    requestFactory.setHttpClient(httpClient);

    return requestFactory;
}</pre></div>



<h2 class="wp-block-heading">Apache HTTP Client pom.xml</h2>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;xml&quot;,&quot;mime&quot;:&quot;application/xml&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;XML&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;xml&quot;}">&lt;dependency&gt;
    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
    &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
&lt;/dependency&gt;

&lt;dependency&gt;
    &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
    &lt;artifactId&gt;httpclient&lt;/artifactId&gt;
&lt;/dependency&gt;</pre></div>



<h2 class="wp-block-heading">Swagger OpenAPI Client</h2>



<p>Furthermore sometimes it is required to remove the SSL check from the OpenAPI Swagger ApiClient.</p>



<h2 class="wp-block-heading">Use the Spring RestTemplate for Swagger Client</h2>



<p>Add the following flag: -Dio.swagger.parser.util.RemoteUrl.trustAll=true&nbsp;</p>



<h2 class="wp-block-heading">Configure Swagger Client</h2>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text/x-java&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Java&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;java&quot;}">// If a using spring rest template assign here the RestTemplate
final XyzApi result = new XyzApi(new ApiClient(restTemplate));</pre></div>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;xml&quot;,&quot;mime&quot;:&quot;application/xml&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;XML&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;xml&quot;}">&lt;plugin&gt;
    &lt;groupId&gt;org.openapitools&lt;/groupId&gt;
    &lt;artifactId&gt;openapi-generator-maven-plugin&lt;/artifactId&gt;
    &lt;executions&gt;
        &lt;execution&gt;
            &lt;id&gt;xyz-client&lt;/id&gt;
          &lt;goals&gt;
            &lt;goal&gt;generate&lt;/goal&gt;
          &lt;/goals&gt;
          &lt;configuration&gt;
          	    &lt;!-- use Spring RestTemaplte, optional --&gt;
                &lt;library&gt;resttemplate&lt;/library&gt;
	            &lt;!-- skip SSL check --&gt;
                &lt;environmentVariables&gt;
                    &lt;io.swagger.parser.util.RemoteUrl.trustAll&gt;true&lt;/io.swagger.parser.util.RemoteUrl.trustAll&gt;
                &lt;/environmentVariables&gt;</pre></div>



<h2 class="wp-block-heading">Links</h2>



<ul class="wp-block-list"><li>https://pragmaticintegrator.wordpress.com/2017/08/13/small-hack-to-avoid-ssl-validation-in-spring-resttemplate/</li><li>http://progressivecoder.com/avoid-ssl-validation-spring-boot-resttemplate/</li><li>https://dev.to/mnpaa/disable-skip-ssl-validation-in-springboot-resttemplate-1ec2</li><li>https://github.com/swagger-api/swagger-codegen/wiki/FAQ#is-there-a-way-to-disable-certificate-verification</li></ul>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sterl.org/2019/06/spring-boot-resttemplate-no-ssl-check/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
