Skip to content

Commit

Permalink
Merge pull request #39 from event-catalog/fix-logging-for-message-ver…
Browse files Browse the repository at this point in the history
…sion-openapi

fix(plugin): fixed message version logging
  • Loading branch information
boyney123 authored Feb 6, 2025
2 parents 73115ff + 600fe8a commit ae38ad4
Show file tree
Hide file tree
Showing 18 changed files with 741 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/hungry-dragons-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@eventcatalog/generator-openapi": patch
---

fix(plugin): fixed message version logging
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ All plugins require a license key. You can get a license key from [EventCatalog

- [Integrate OpenAPI files into EventCatalog](./examples/generator-openapi/)
- [Integrate OpenAPI files from remote URLs into EventCatalog](./examples/generator-openapi/fetch-from-remote-urls/)
- [Independent Message Versioning using the `x-eventcatalog-message-version` extension](./examples/generator-openapi/independent-message-versioning/)

**AsyncAPI Integrations**

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# EventCatalog OpenAPI Example - Independent Message Versioning

This example shows you how you can use the `x-eventcatalog-message-version` extension to assign a version to each message in your OpenAPI file.

By default EventCatalog will use the version of your OpenAPI file for all messages in that specification.

If you prefer to assign a version to each message, you can use the `x-eventcatalog-message-version` extension.

This example contains:

- Assigning a version to each message in an OpenAPI file
- Using EventCatalog with many OpenAPI Files
- Assigning OpenAPI files to domains in the eventcatalog.config.js file

### Getting Started

1. Clone this project
1. Run `npm install`
1. Get a OpenAPI license key from [OpenAPI](https://eventcatalog.cloud) (14 day free trial)
1. Run the generators `npm run generate`
1. Run the catalog `npm run dev`
1. View your catalog at https://localhost:3000

### Features for OpenAPI Plugin

- Auto versioning of domains, services and messages
- Document events, queries and commands using custom extensions to OpenAPI
- Assign each route/message a version independent of your OpenAPI version
- Visually see OpenAPI files in your catalog.
- And much more...

To dive into how this plugin can help you, you can read the [OpenAPI Plugin Docs](https://www.eventcatalog.dev/integrations/openapi)




Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import path from "path";
import url from "url";

const __dirname = path.dirname(url.fileURLToPath(import.meta.url));

/** @type {import('@eventcatalog/core/bin/eventcatalog.config').Config} */
export default {
cId: "10b46030-5736-4600-8254-421c3ed56e47",
title: "EventCatalog",
tagline: "Discover, Explore and Document your Event Driven Architectures",
organizationName: "Your Company",
homepageLink: "https://eventcatalog.dev/",
editUrl: "https://github.com/boyney123/eventcatalog-demo/edit/master",
// By default set to false, add true to get urls ending in /
trailingSlash: false,
// Change to make the base url of the site different, by default https://{website}.com/docs,
// changing to /company would be https://{website}.com/company/docs,
base: "/",
// Customize the logo, add your logo to public/ folder
logo: {
alt: "EventCatalog Logo",
src: "/logo.png",
text: "EventCatalog",
},
docs: {
sidebar: {
// Should the sub heading be rendered in the docs sidebar?
showPageHeadings: true,
},
},
generators: [
[
"@eventcatalog/generator-openapi",
{
services: [
{ path: path.join(__dirname, "openapi-files", "product-api.yml") },
],
domain: { id: "products", name: "Products", version: "0.0.1" },
},
],
[
"@eventcatalog/generator-openapi",
{
services: [
{ path: path.join(__dirname, "openapi-files", "order-api.yml"), id: 'order-service' },
{ path: path.join(__dirname, "openapi-files", "order-history.yml"), id: 'order-history' },
],
domain: {
id: "order-management",
name: "Order management",
version: "0.0.1",
},
},
],
[
"@eventcatalog/generator-openapi",
{
services: [
{ path: path.join(__dirname, "openapi-files", "payment-api.yml"), id: 'payment-service' },
],
domain: { id: "payment", name: "Payment", version: "0.0.1" },
},
],
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* Custom styling support coming soon. */
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
openapi: 3.0.0
info:
title: Cart API
description: API for managing shopping cart operations.
version: 1.0.0
servers:
- url: https://api.yourshoppingapp.com/cart
description: Cart API Server
paths:
/:
get:
summary: Retrieve shopping cart
description: Get the contents of the user's shopping cart.
x-eventcatalog-message-type: query
x-eventcatalog-message-version: 1.0.0
operationId: getCart
responses:
'200':
description: Shopping cart details
content:
application/json:
schema:
$ref: '#/components/schemas/Cart'
post:
summary: Add item to cart
description: Add a product to the shopping cart.
x-eventcatalog-message-type: command
x-eventcatalog-message-version: 1.0.0
requestBody:
description: Product information to add to the cart.
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CartItem'
responses:
'201':
description: Product added to cart
content:
application/json:
schema:
$ref: '#/components/schemas/Cart'
/{productId}:
patch:
summary: Update item quantity
description: Update the quantity of an item in the cart.
x-eventcatalog-message-type: command
x-eventcatalog-message-version: 1.0.0
operationId: updateCartItem
parameters:
- name: productId
in: path
required: true
schema:
type: string
requestBody:
description: Updated quantity
required: true
content:
application/json:
schema:
type: object
properties:
quantity:
type: integer
minimum: 1
responses:
'200':
description: Quantity updated
'404':
description: Product not found in cart
delete:
summary: Remove item from cart
description: Remove a product from the shopping cart.
x-eventcatalog-message-type: command
parameters:
- name: productId
in: path
required: true
schema:
type: string
responses:
'204':
description: Product removed from cart
components:
schemas:
Cart:
type: object
properties:
items:
type: array
items:
$ref: '#/components/schemas/CartItem'
CartItem:
type: object
properties:
productId:
type: string
name:
type: string
quantity:
type: integer
price:
type: number
format: float
required:
- productId
- name
- quantity
- price
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
openapi: 3.0.0
info:
title: Order API
description: API for managing orders in the shopping application.
version: 1.0.0
servers:
- url: https://api.yourshoppingapp.com/orders
description: Order API Server
paths:
/:
get:
summary: Get list of orders
description: Retrieve a list of all orders made by the user.
x-eventcatalog-message-type: query
x-eventcatalog-message-version: 5.0.0
operationId: listOrders
responses:
'200':
description: A list of orders
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Order'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/{orderId}:
get:
summary: Get order by ID
description: Retrieve details of a specific order.
operationId: getOrderById
x-eventcatalog-message-type: query
x-eventcatalog-message-version: 5.0.0
parameters:
- name: orderId
in: path
required: true
schema:
type: string
responses:
'200':
description: Order details
content:
application/json:
schema:
$ref: '#/components/schemas/Order'
'404':
description: Order not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
patch:
summary: Update order status
description: Update the status of an order (e.g., cancel).
x-eventcatalog-message-type: command
x-eventcatalog-message-version: 5.0.0
parameters:
- name: orderId
in: path
required: true
schema:
type: string
requestBody:
description: Updated order status
required: true
content:
application/json:
schema:
type: object
properties:
status:
type: string
enum: [pending, shipped, delivered, canceled]
responses:
'200':
description: Order status updated
'404':
description: Order not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
components:
schemas:
Order:
type: object
properties:
id:
type: string
items:
type: array
items:
$ref: '#/components/schemas/CartItem'
status:
type: string
enum: [pending, shipped, delivered, canceled]
totalAmount:
type: number
format: float
required:
- id
- items
- status
- totalAmount
CartItem:
type: object
properties:
productId:
type: string
name:
type: string
quantity:
type: integer
price:
type: number
format: float
required:
- productId
- name
- quantity
- price
ErrorResponse:
type: object
properties:
code:
type: integer
description: Error code representing the issue
message:
type: string
description: A description of the error
required:
- code
- message
Loading

0 comments on commit ae38ad4

Please sign in to comment.