
openapi: 3.1.0
info:
  title: JSONPlaceholder - OpenAPI 3.1
  description: |-
    This is a sample OpenAPI 3.1 specification for the JSONPlaceholder Posts API.

    Some useful links:
    - [JSONPlaceholder](https://jsonplaceholder.typicode.com)
  termsOfService: http://swagger.io/terms/
  contact:
    email: jacquelineb@communityplatform.com
  license:
    name: MIT
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  version: 1.0.0
externalDocs:
  description: Find out more about Swagger
  url: http://swagger.io
servers:
  - url: https://jsonplaceholder.typicode.com
tags:
  - name: Post
    description: JSONPlaceholder Posts

paths:
  /posts:
    get:
      tags:
        - Post
      summary: Get all posts
      operationId: getPosts
      responses:
        '200':
          description: A list of posts
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Post'
    post:
      tags:
        - Post
      summary: Create a new post
      operationId: createPost
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PostInput'
      responses:
        '201':
          description: Post created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Post'

  /posts/{id}:
    get:
      tags:
        - Post
      summary: Get a post by ID
      operationId: getPostById
      parameters:
        - name: id
          in: path
          required: true
          description: ID of the post
          schema:
            type: integer
      responses:
        '200':
          description: Post found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Post'
        '404':
          description: Post not found

components:
  schemas:
    Post:
      type: object
      properties:
        userId:
          type: integer
        id:
          type: integer
        title:
          type: string
        body:
          type: string
      required: [userId, id, title, body]

    PostInput:
      type: object
      properties:
        userId:
          type: integer
        title:
          type: string
        body:
          type: string
      required: [userId, title, body]
