<?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: Valériane Venance</title>
    <description>The latest articles on DEV Community by Valériane Venance (@vvenance).</description>
    <link>https://dev.to/vvenance</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%2F1083762%2F63d7b7d7-7a1d-41c7-817f-635271678e0f.png</url>
      <title>DEV Community: Valériane Venance</title>
      <link>https://dev.to/vvenance</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vvenance"/>
    <language>en</language>
    <item>
      <title>Perfectly sizing images in your API documentation</title>
      <dc:creator>Valériane Venance</dc:creator>
      <pubDate>Wed, 02 Aug 2023 14:59:13 +0000</pubDate>
      <link>https://dev.to/bump/perfectly-sizing-images-in-your-api-documentation-1kc0</link>
      <guid>https://dev.to/bump/perfectly-sizing-images-in-your-api-documentation-1kc0</guid>
      <description>&lt;p&gt;Images are cool and they should be everywhere in your API doc. End of this blog post, thanks everyone!&lt;/p&gt;

&lt;p&gt;Well, more seriously, many people, obviously including me, love a nice visual, especially when it comes to learning something new like, let’s say… how to use a new API. Bump.sh always supported the ability to add images in the markdown of your API documentation and has now extended it with the ability of sizing to your needs.&lt;/p&gt;

&lt;p&gt;Whether you want to have your API documentation more lively to your users with gifs, share your &lt;a href="https://bump.sh/blog/api-architecture-diagrams"&gt;API diagrams&lt;/a&gt;, illustrate complex API behaviors (like &lt;a href="https://bump.sh/blog/use-document-polymorphism-API"&gt;polymorphism&lt;/a&gt;) with a nice visual, and you have an API Contract based on &lt;a href="https://bump.sh/blog/what-is-openapi"&gt;OpenAPI&lt;/a&gt; or &lt;a href="https://bump.sh/blog/what-is-asyncapi"&gt;AsyncAPI&lt;/a&gt;, you can now make sure the images in your API documentation renders in the size you’d prefer them to.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Bump.sh renders images by default
&lt;/h2&gt;

&lt;p&gt;Usually, in markdown, you would use this syntax to add an image&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="p"&gt;![&lt;/span&gt;&lt;span class="nv"&gt;Alt text&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="sx"&gt;/path/to/image.jpg&lt;/span&gt; &lt;span class="nn"&gt;"Image title"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By default Bump.sh lets the browser decide how it will display the generated html &lt;code&gt;&amp;lt;img src="image.url"&amp;gt;&lt;/code&gt;. For instance if the image is in a table cell, it will be limited to the size of the table cell, if in a paragraph, it will use the default image size.&lt;/p&gt;

&lt;p&gt;However, you can now decide on the image size yourself.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to customize the image size in your API documentation
&lt;/h2&gt;

&lt;p&gt;Now you can take it a step even further into the personalisation with a &lt;code&gt;=dimension&lt;/code&gt; parameter that lets you manually decide how your image should be displayed in your documentation.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;=dimension&lt;/code&gt; just extends the well known Markdown syntax by allowing you to give extra dimension information before the closing parenthesis&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="p"&gt;![&lt;/span&gt;&lt;span class="nv"&gt;Alt text&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="sx"&gt;/path/to/image.jpg&lt;/span&gt; &lt;span class="nn"&gt;"Image title"&lt;/span&gt; =dimension)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As an example, if you wanted to display an image of 100 pixels height and 50 pixels width you could write&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="p"&gt;![&lt;/span&gt;&lt;span class="nv"&gt;Alt text&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="sx"&gt;/path/to/image.jpg&lt;/span&gt; &lt;span class="nn"&gt;"Image title"&lt;/span&gt; =100pxx50px)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;=dimension&lt;/code&gt; uses the following syntax &lt;code&gt;=[width][unit]x[height][unit]&lt;/code&gt; and is itself completely optional as well as almost all its parameters: just &lt;code&gt;width&lt;/code&gt; &lt;em&gt;or&lt;/em&gt; &lt;code&gt;x&lt;/code&gt; + &lt;code&gt;height&lt;/code&gt; are mandatory. If you don't specify &lt;code&gt;width&lt;/code&gt; &lt;em&gt;or&lt;/em&gt; &lt;code&gt;height&lt;/code&gt;, the other value will be a ratio calculated from the original size of the image so it doesn't shrink.&lt;/p&gt;

&lt;p&gt;Telling this might be confusing so here are a few examples to better understand what you can do with this &lt;code&gt;=dimension&lt;/code&gt; parameter:&lt;/p&gt;

&lt;p&gt;Let’s take this SpongeBob plushie picture. See how it renders by default:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZOGEhs8I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.imgur.com/cu8U4wq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZOGEhs8I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.imgur.com/cu8U4wq.png" alt="SpongeBob plushie image in a Bump.sh documentation" width="800" height="880"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And now let’s play around with the &lt;code&gt;=dimension&lt;/code&gt; parameter!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=100pxx50px   # with everything
=100x50     # without unit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fERG_g05--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.imgur.com/d6wu60d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fERG_g05--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.imgur.com/d6wu60d.png" alt="SpongeBob plushie image in a Bump.sh documentation with 150 x 50 px sizing" width="242" height="158"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=100        # without height (x separator not needed) and unit
=100px      # without height
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--r6qGbK0W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.imgur.com/jExxH3b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--r6qGbK0W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.imgur.com/jExxH3b.png" alt="SpongeBob plushie image in a Bump.sh documentation with 100px sizing" width="254" height="288"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=x50        # without width and unit
=x50px      # without width
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9gyUyl0p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.imgur.com/BSJfnXr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9gyUyl0p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.imgur.com/BSJfnXr.png" alt="SpongeBob plushie image in a Bump.sh documentation with 100px sizing" width="108" height="144"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that not specifying an unit will fall back to pixel.&lt;/p&gt;

&lt;p&gt;It also supports all CSS length units, so you can work with &lt;code&gt;px&lt;/code&gt; for pixel, &lt;code&gt;%&lt;/code&gt;, or any other absolute or relative unit you are used to.&lt;/p&gt;

&lt;p&gt;Same image as above with &lt;code&gt;=dimension&lt;/code&gt;set to &lt;code&gt;=200cm&lt;/code&gt;:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WEmeePUD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.imgur.com/vcyBg4g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WEmeePUD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.imgur.com/vcyBg4g.png" alt="SpongeBob plushie image in a Bump.sh documentation with 200cm sizing" width="498" height="534"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Always make sure how the property you use is handled by different browsers as it may differ.&lt;/p&gt;

&lt;p&gt;You can find an extended description of the behavior of this new image sizing feature &lt;a href="https://docs.bump.sh/help/specifications-support/markdown-support/#image-sizing"&gt;in the documentation&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Trying with your own API documentation
&lt;/h2&gt;

&lt;p&gt;Bump.sh lets you preview how your documentation would look like.&lt;/p&gt;

&lt;p&gt;You can preview how your images will render while editing your API contract or in your tests using the &lt;a href="https://github.com/bump-sh/cli"&gt;Bump.sh CLI&lt;/a&gt; with the command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; bump-cli   &lt;span class="c"&gt;## installs bump.sh cli&lt;/span&gt;

bump preview &lt;span class="nt"&gt;--live&lt;/span&gt; &lt;span class="nt"&gt;--open&lt;/span&gt; openapi-definition.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Option &lt;code&gt;--open&lt;/code&gt; will open the preview in your default browser, and &lt;code&gt;--live&lt;/code&gt; will automatically update the preview in your browser upon saving edits in the file.&lt;/p&gt;

&lt;p&gt;And do you know what’s best? You don’t even need a &lt;a href="https://bump.sh/users/sign_up?utm_source=bump&amp;amp;utm_medium=blog&amp;amp;utm_campaign=perfectly-sizing-images-blog"&gt;Bump.sh account&lt;/a&gt; to use our preview, so enjoy playing around with images to see how your API documentation could render with perfectly sized images 🖼️!&lt;/p&gt;

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

&lt;p&gt;Images are cool and they should be everywhere in your API doc.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xp34Wnp---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.imgur.com/P6bkeWG.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xp34Wnp---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.imgur.com/P6bkeWG.png" alt="Images Everywhere meme" width="620" height="465"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Valériane Venance is Principal Developer Advocate at Bump.sh. She loves writing docs and articles. You can &lt;a href="https://twitter.com/intent/user?screen_name=Valeriane_IT"&gt;follow her&lt;/a&gt; on Twitter or &lt;a href="https://www.linkedin.com/in/vvenance/"&gt;connect&lt;/a&gt; on LinkedIn&lt;/em&gt;&lt;/p&gt;

</description>
      <category>openapi</category>
      <category>asyncapi</category>
      <category>apidocumentation</category>
      <category>documentation</category>
    </item>
  </channel>
</rss>
