Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

open-api: merge operations from template file #3578

Closed
jknack opened this issue Nov 10, 2024 · 0 comments
Closed

open-api: merge operations from template file #3578

jknack opened this issue Nov 10, 2024 · 0 comments

Comments

@jknack
Copy link
Member

jknack commented Nov 10, 2024

There is an existing basic merge function described here. The goal of this feature is to support paths and operations. Like:

openapi-template.yaml:

openapi: 3.0.1
info:
  title: Pets API
  description: Nunc fermentum ipsum id bibendum blandit. Praesent sagittis est ut.
  version: "1.0"
paths:
  /api/pets:
    get:
      operationId: listPets
    post:
      operationId: createPet
  /api/pets/{id}:
    get:
      operationId: findPetById
    put:
      operationId: updatePet
      description: Update a valid pet
    delete:
      operationId: deletePet
      description: Delete a Pet from database
      parameters:
      - name: id
        description: Pet ID to delete   

App.java

{
    path("/api/pets", () -> {
      get("/", ...);
      get("/{id}", ...);
      post("/",  ...);
      put("/{id}", ...);
      delete("/{id}", ...);
    });
  }

Generates:

1
info:
  title: Pets API
  description: Nunc fermentum ipsum id bibendum blandit. Praesent sagittis est ut.
  version: "1.0"
paths:
  /api/pets:
    get:
      operationId: listPets
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                type: string
    post:
      operationId: createPet
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                type: string
  /api/pets/{id}:
    get:
      operationId: findPetById
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                type: string
    put:
      description: Update a valid pet
      operationId: updatePet
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                type: string
    delete:
      description: Delete a Pet from database
      operationId: deletePet
      parameters:
      - name: id
        in: path
        description: Pet ID to delete
        required: true
        schema:
          type: string
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                type: string

This complement auto-generated file with more descriptive documentation

😎

@jknack jknack added this to the 3.5.2 milestone Nov 10, 2024
@jknack jknack closed this as completed in 2ba0124 Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant