<?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: Miralem Drek</title>
    <description>The latest articles on DEV Community by Miralem Drek (@miralemd).</description>
    <link>https://dev.to/miralemd</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%2F56741%2F3b9e1ca7-a3b0-43a1-8a2d-c2a7fe7a1c0e.png</url>
      <title>DEV Community: Miralem Drek</title>
      <link>https://dev.to/miralemd</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/miralemd"/>
    <language>en</language>
    <item>
      <title>Towards a JavaScript API Specification</title>
      <dc:creator>Miralem Drek</dc:creator>
      <pubDate>Tue, 06 Feb 2018 13:40:28 +0000</pubDate>
      <link>https://dev.to/miralemd/towards-a-javascript-api-specification-35ee</link>
      <guid>https://dev.to/miralemd/towards-a-javascript-api-specification-35ee</guid>
      <description>&lt;p&gt;In the past few years &lt;a href="https://github.com/OAI/OpenAPI-Specification"&gt;OpenAPI&lt;/a&gt; (formerly Swagger) has become a de-facto standard for describing REST APIs, while a format for non-REST APIs is still to be defined.&lt;/p&gt;

&lt;p&gt;This is particularly challenging in dynamically typed languages like JavaScript, which despite its popularity still has no consistent way to describe an API for a consumer.&lt;/p&gt;

&lt;p&gt;Various formats do exist though and each project/vendor seems to have their own way of describing their interface:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The JSON output from the &lt;a href="https://github.com/jsdoc3/jsdoc"&gt;JSDoc3&lt;/a&gt; project comes a long way, but it's primary focus is to generate documentation, not describe the annotated API.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/documentationjs/documentation"&gt;documentationjs&lt;/a&gt; also provides a very good JSON structure, but again the project is more focused on generating documentation.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/esdoc/esdoc"&gt;esdoc&lt;/a&gt; has a very good plugin architecture, outputting a structured JSON should be possible.&lt;/li&gt;
&lt;li&gt;NodeJS has a JSON representation of each one of their modules, e.g. &lt;a href="https://nodejs.org/api/net.html"&gt;net.html&lt;/a&gt; and &lt;a href="https://nodejs.org/api/net.json"&gt;net.json&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Goal
&lt;/h2&gt;

&lt;p&gt;What I'm interested in is to define a standard for describing JavaScript APIs. By defining a machine-readable format of the consumable API, additional tools can be created based on the provided specification:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Generate API reference documentation&lt;/li&gt;
&lt;li&gt;Generate typings (TypeScript, Flow etc.)&lt;/li&gt;
&lt;li&gt;Visualize the API to provide an overview&lt;/li&gt;
&lt;li&gt;Assist in API governance by comparing versions and detecting added/deprecated/removed endpoints&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Much like the Open API specification, I have started with a &lt;a href="https://github.com/miralemd/js-api-spec"&gt;rough draft of such a format&lt;/a&gt;, complemented with a JSON-schema and a &lt;a href="https://github.com/miralemd/jsdoc2spec"&gt;tool which can transform JSDoc annotated code&lt;/a&gt; to said specification.&lt;/p&gt;

&lt;p&gt;Do you think a specification for JavaScript APIs could be useful? Unnecessary? Do you have any feedback on the current draft? Let me know what you think.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>api</category>
      <category>specification</category>
    </item>
  </channel>
</rss>
