Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy
Ajax

AJAX: REST API Documentation with OpenAPI

- 15.08.26 - ErcanOPAK

📖 OpenAPI = API Documentation

Good APIs need good docs. OpenAPI provides standardized, interactive documentation for your REST APIs.

📝 OpenAPI Specification

# openapi.yaml
openapi: 3.0.0
info:
    title: My API
    version: 1.0.0
    description: API documentation

paths:
    /users:
        get:
            summary: Get all users
            description: Returns a list of users
            parameters:
                - name: page
                  in: query
                  schema:
                      type: integer
                      default: 1
                - name: limit
                  in: query
                  schema:
                      type: integer
                      default: 20
            responses:
                200:
                    description: Success
                    content:
                        application/json:
                            schema:
                                type: array
                                items:
                                    $ref: '#/components/schemas/User'

    /users/{id}:
        get:
            summary: Get user by ID
            parameters:
                - name: id
                  in: path
                  required: true
                  schema:
                      type: integer
            responses:
                200:
                    description: User found
                    content:
                        application/json:
                            schema:
                                $ref: '#/components/schemas/User'
                404:
                    description: User not found

components:
    schemas:
        User:
            type: object
            properties:
                id:
                    type: integer
                name:
                    type: string
                email:
                    type: string
                created_at:
                    type: string
                    format: date-time

🎯 Tools and Integration

# Swagger UI
npm install swagger-ui-express

// Server Setup
const swaggerUi = require('swagger-ui-express');
const swaggerDocument = require('./openapi.json');

app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));

# ReDoc
npm install redoc-express
const redoc = require('redoc-express');

app.get('/api-docs', redoc({
    title: 'API Documentation',
    specUrl: '/openapi.json'
}));

# Code Generation
openapi-generator generate -i openapi.yaml -g typescript-axios

# Validation
npm install swagger-cli
swagger-cli validate openapi.yaml

# Testing
npm install @openapi-contrib/openapi-schema-to-json-schema

# Security
npm install swagger-parser
swagger-parser validate openapi.yaml

💡 API Documentation Tips

  • Keep documentation up-to-date
  • Use examples in documentation
  • Include error responses
  • Add authentication details
  • Provide interactive testing

OpenAPI makes API documentation interactive and maintainable. It’s essential for modern API development.

— API Architect

Related posts:

Ajax: Ensuring Data Delivery with the 'keepalive' Flag

Ajax: Ensuring Data Delivery with the 'keepalive' Flag

Ajax: Fix a Cancelled Request Still Updating Stale UI State

Ajax: Fix a Cancelled Request Still Updating Stale UI State

Ajax: Fix Concurrent fetch() Calls to the Same Endpoint Triggering the Server's Rate Limiter Because...

Ajax: Fix Concurrent fetch() Calls to the Same Endpoint Triggering the Server's Rate Limiter Because...

Views: 8

Post navigation

JavaScript: Working with Promises and Async/Await
Git: Resolving Merge Conflicts Like a Pro

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

November 2026
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  
« Oct    

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,068)
  • Get the User Name and Domain Name from an Email Address in SQL (990)
  • How to add default value for Entity Framework migrations for DateTime and Bool (986)
  • Get the First and Last Word from a String or Sentence in SQL (865)
  • How to select distinct rows in a datatable in C# (859)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (661)
  • Add Constraint to SQL Table to ensure email contains @ (619)
  • Average of all values in a column that are not zero in SQL (577)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (553)
  • Find numbers with more than two decimal places in SQL (481)

Recent Posts

  • Network Speed Monitor Windows Application v2.5.1
  • Ağ Hızı İzleyici Windows Uygulaması v2.5.1
  • How to make theater mode the default for Youtube
  • The AI Prompt That Audits a Function for Thread-Safety Gaps
  • Ajax: Fix a Fetch Request Caching a Response Despite No-Store
  • WordPress: Fix a Navigation Block Losing Submenu Items After Sync
  • Visual Studio: Fix CodeLens Reference Counts Stuck at Stale Numbers
  • C#: Fix a UTF-8 String Literal Behaving Differently in a Switch
  • Photoshop: Fix a Liquify Mesh Snapping Back on a Smart Object
  • The AI Prompt That Turns a Crash Dump Into a Short Repro Script

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,068)
  • Get the User Name and Domain Name from an Email Address in SQL (990)
  • How to add default value for Entity Framework migrations for DateTime and Bool (986)
  • Get the First and Last Word from a String or Sentence in SQL (865)
  • How to select distinct rows in a datatable in C# (859)

Recent Posts

  • Network Speed Monitor Windows Application v2.5.1
  • Ağ Hızı İzleyici Windows Uygulaması v2.5.1
  • How to make theater mode the default for Youtube
  • The AI Prompt That Audits a Function for Thread-Safety Gaps
  • Ajax: Fix a Fetch Request Caching a Response Despite No-Store

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com