<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ankit Jain</title>
    <description>The latest articles on DEV Community by Ankit Jain (@ajatkj).</description>
    <link>https://dev.to/ajatkj</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F751754%2F75427190-2153-4feb-a349-ce5fcd5cb6f9.jpeg</url>
      <title>DEV Community: Ankit Jain</title>
      <link>https://dev.to/ajatkj</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ajatkj"/>
    <language>en</language>
    <item>
      <title>A fully typed configparser for python</title>
      <dc:creator>Ankit Jain</dc:creator>
      <pubDate>Wed, 24 Jan 2024 13:30:51 +0000</pubDate>
      <link>https://dev.to/ajatkj/a-fully-typed-configparser-for-python-145a</link>
      <guid>https://dev.to/ajatkj/a-fully-typed-configparser-for-python-145a</guid>
      <description>&lt;p&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CHIK9Trr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://raw.githubusercontent.com/ajatkj/typed_configparser/main/assets/logo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CHIK9Trr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://raw.githubusercontent.com/ajatkj/typed_configparser/main/assets/logo.png" alt="Description of the image" width="300" height="176"&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  typed-configparser
&lt;/h2&gt;

&lt;p&gt;typed-configparser is an extension of the standard configparser module with support for typed configurations using dataclasses.&lt;br&gt;
It leverages Python's type hints and &lt;code&gt;dataclasses&lt;/code&gt; to provide a convenient way of parsing and validating configuration files.&lt;/p&gt;
&lt;h3&gt;
  
  
  Features
&lt;/h3&gt;

&lt;p&gt;✓ Fully typed.&lt;br&gt;
✓ Use dataclasses to parse the configuration file.&lt;br&gt;
✓ Support for almost all python built-in data types - &lt;code&gt;int&lt;/code&gt;, &lt;code&gt;float&lt;/code&gt;, &lt;code&gt;str&lt;/code&gt;, &lt;code&gt;list&lt;/code&gt;, &lt;code&gt;tuple&lt;/code&gt;, &lt;code&gt;dict&lt;/code&gt; and complex data types using &lt;code&gt;Union&lt;/code&gt; and &lt;code&gt;Optional&lt;/code&gt;.&lt;br&gt;
✓ Built on top of &lt;code&gt;configparser&lt;/code&gt;, hence retains all functionalities of &lt;code&gt;configparser&lt;/code&gt;.&lt;br&gt;
✓ Support for optional values (optional values are automatically set to &lt;code&gt;None&lt;/code&gt; if not provided).&lt;br&gt;
✓ Smarter defaults.&lt;/p&gt;
&lt;h3&gt;
  
  
  Usage
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;examples/basic.py&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# This is a complete example and should work as is

from typing import List
from typed_configparser import ConfigParser
from dataclasses import dataclass


@dataclass
class BASIC:
    option1: int
    option2: str
    option3: float
    option4: List[str]


config = """
[BASIC]
option1 = 10
option2 = value2
option3 = 5.2
option4 = [foo,bar]
"""

parser = ConfigParser()
parser.read_string(config)
section = parser.parse_section(using_dataclass=BASIC)

print(section)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BASIC(option1=10, option2=value2, option3=5.2, option4=['foo', 'bar'])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;examples/unions_and_optionals.py&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# This is a complete example and should work as is

from typing import List, Union, Optional, Dict, Tuple
from typed_configparser import ConfigParser
from dataclasses import dataclass, field


@dataclass
class DEFAULT_EXAMPLE:
    option1: int
    option2: Union[List[Tuple[str, str]], List[int]]
    option3: Dict[str, str] = field(default_factory=lambda: {"default_key": "default_value"})
    option4: Optional[float] = None


config = """
[DEFAULT]
option1 = 20
option2 = default_value2

[MY_SECTION_1]
option2 = [10,20]
option4 = 5.2

[MY_SECTION_2]
option2 = [(value2a, value2b), (value2c, value2b), (value2c, value2d)]
option3 = {key: value}
option4 = none
"""

parser = ConfigParser()
parser.read_string(config)
my_section_1 = parser.parse_section(using_dataclass=DEFAULT_EXAMPLE, section_name="MY_SECTION_1")
my_section_2 = parser.parse_section(using_dataclass=DEFAULT_EXAMPLE, section_name="MY_SECTION_2")

print(my_section_1)
print(my_section_2)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DEFAULT_EXAMPLE(option1=20, option2=[10, 20], option3={'default_key': 'default_value'}, option4=5.2)
DEFAULT_EXAMPLE(option1=20, option2=[('value2a', 'value2b'), ('value2c', 'value2b'), ('value2c', 'value2d')], option3={'key': 'value'}, option4=None)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the &lt;a href="https://github.com/ajatkj/typed_configparser"&gt;github repo&lt;/a&gt; for more details.&lt;/p&gt;

</description>
      <category>python</category>
      <category>typed</category>
      <category>configparser</category>
      <category>dataclasses</category>
    </item>
    <item>
      <title>A new &amp; improved Swagger UI theme</title>
      <dc:creator>Ankit Jain</dc:creator>
      <pubDate>Tue, 16 Jan 2024 15:34:04 +0000</pubDate>
      <link>https://dev.to/ajatkj/a-new-improved-swagger-ui-theme-32ho</link>
      <guid>https://dev.to/ajatkj/a-new-improved-swagger-ui-theme-32ho</guid>
      <description>&lt;h2&gt;
  
  
  swagger-ui-improved-theme
&lt;/h2&gt;

&lt;p&gt;Welcome to Swagger UI Improved Theme, a project aimed at enhancing the visual appeal of Swagger UI documentation. If you've ever found Swagger UI to be a bit bland and in need of a facelift, you're in the right place. This theme strives to make Swagger UI documentation look cooler and more visually engaging. Be sure to check out the screenshots to see the theme in action!&lt;/p&gt;

&lt;h3&gt;
  
  
  Note
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The theme is designed to work seamlessly with OpenAPI v3 and above.&lt;/li&gt;
&lt;li&gt;It also provides support for Swagger v2, though it may not be fully tested. Most features should work fine, but keep in mind that future updates will focus primarily on v3 and above.&lt;/li&gt;
&lt;li&gt;In the event that a change in the OpenAPI specification breaks compatibility with Swagger v2, it will not be actively addressed in future updates.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How to use?
&lt;/h3&gt;

&lt;p&gt;Using the Swagger UI Improved Theme is a breeze. You have two options:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Download Locally:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Simply download the CSS file from this repository and include it in your project.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Use a CDN - jsDelivr:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Copy and paste the following URL into your project:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt; https://cdn.jsdelivr.net/gh/ajatkj/swagger-ui-improved-theme/css/swagger-ui-improved.css
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;This allows you to seamlessly integrate the theme into your Swagger UI documentation without the need to host the file yourself.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Screenshots
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fymstv73y8r6zsly6974t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fymstv73y8r6zsly6974t.png" alt="screenshot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F25n11lzazdifm0jz6pfg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F25n11lzazdifm0jz6pfg.png" alt="screenshot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Contributions
&lt;/h3&gt;

&lt;p&gt;If you're passionate about improving Swagger UI documentation and have ideas for enhancements, feel free to contribute to this project. Open-source thrives on collaboration, and your input could make a significant impact.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Swagger UI Improved Theme aims to inject style and modern aesthetics into your API documentation. Whether you're working with OpenAPI v3 or Swagger v2, this theme provides an opportunity to showcase your API in a visually appealing way. Download it, give it a try, and let your Swagger UI documentation stand out from the crowd!&lt;/p&gt;

</description>
      <category>swagger</category>
      <category>themes</category>
      <category>openapi</category>
      <category>css</category>
    </item>
  </channel>
</rss>
