Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@geniegeist
Copy link
Contributor

@geniegeist geniegeist commented Aug 6, 2025

Overview

This PR implements an OpenAPI plugin (see #12). It uses libopenapi under the hood to parse the OpenAPI specs; I've used libopenapi in the past (and also made some minor contributions to it), and it is a great library. Let me know if you have concerns.

Features

  • Creates a Service asset for each OpenAPI specification
  • Creates an Endpoint asset for each operation object found in an OpenAPI specification

Overview

Screenshot 2025-08-12 at 16 12 20

Service Asset

Screenshot 2025-08-12 at 16 13 27 Screenshot 2025-08-12 at 16 14 04 Screenshot 2025-08-12 at 16 14 22

Endpoint Asset

Screenshot 2025-08-12 at 16 14 38

Tests

✅ E2E tests pass on my local machine.

Example

  1. Put an openapi.yaml in the directory app/openapi-specs (for example, take the Stripe API)
  2. Create an example.yaml file with the content
runs:
- openapi:
    spec_path: "app/openapi-specs"
    tags: 
    - Labubu
  1. Run
go run cmd/main.go ingest -c example.yaml -H http://localhost:8080 -k <API_KEY>

@geniegeist geniegeist marked this pull request as draft August 6, 2025 15:41
@geniegeist geniegeist changed the title Create OpenAPI plugin Draft: Create OpenAPI plugin Aug 6, 2025
@charlie-haley
Copy link
Member

Thanks for the PR @geniegeist, looks great so far. To answer your questions:

  • I think creating a Service asset for the core API would make the most sense as it aligns with what we have for AsyncAPI
    • Endpoint or Path make sense for the asset types, I'm happy with either! Endpoint might be more flexible further down the line
  • Usually that happens if something is running on a clashing port, so if you have postgres or make dev running still, you'll need to stop them. I'll look at adding some better checks to ensure the ports are free before running.

I managed to get them running on my machine at least, let me know if stopping anything with a port clash still doesn't help and I can do some digging

=== RUN   TestOpenAPIIngestion
    openapi_test.go:282: Spec file found: openapi.yaml (size: 8735, mode: -rw-r--r--)
    openapi_test.go:286: Contents of /tmp/openapi-specs:
    openapi_test.go:288:   - openapi.yaml
2025/08/06 19:28:22 Starting container:
2025/08/06 19:28:23 Container started successfully:  (16f5b89c0854c56f620b524ee3c127a017ef32db22c9e01cb703cb6f8e47cf2a)
2025/08/06 19:28:23 Cleaning up container: 16f5b89c0854c56f620b524ee3c127a017ef32db22c9e01cb703cb6f8e47cf2a
2025/08/06 19:28:23 Container 16f5b89c0854c56f620b524ee3c127a017ef32db22c9e01cb703cb6f8e47cf2a cleaned up successfully
2025/08/06 19:28:23 Starting container:
2025/08/06 19:28:23 Container started successfully:  (22a093a459a29ba1fb22f4811bfb6c9fd78f97d41adb597aa1bbb28cb6c83eec)
    openapi_test.go:326: Debug container output: JOCI runtime exec failed: exec failed: cannot exec in a stopped container
    openapi_test.go:328: Ingest command executed, waiting for assets...
    openapi_test.go:351:
        	Error Trace:	/home/charlie/Code/marmot/test/e2e/openapi_test.go:351
        	Error:      	Expected value not to be nil.
        	Test:       	TestOpenAPIIngestion
        	Messages:   	OpenAPI service not found
2025/08/06 19:28:26 Cleaning up container: 22a093a459a29ba1fb22f4811bfb6c9fd78f97d41adb597aa1bbb28cb6c83eec
2025/08/06 19:28:26 Container 22a093a459a29ba1fb22f4811bfb6c9fd78f97d41adb597aa1bbb28cb6c83eec cleaned up successfully
--- FAIL: TestOpenAPIIngestion (3.46s)

@geniegeist
Copy link
Contributor Author

  • I think creating a Service asset for the core API would make the most sense as it aligns with what we have for AsyncAPI
    • Endpoint or Path make sense for the asset types, I'm happy with either! Endpoint might be more flexible further down the line

Thanks for your input. I'll create a service asset then and an endpoint asset for each found path object in the openapi spec.

Usually that happens if something is running on a clashing port, so if you have postgres or make dev running still, you'll need to stop them. I'll look at adding some better checks to ensure the ports are free before running.

I managed to fix my docker setup. Not sure what the error was 👍.

@geniegeist geniegeist changed the title Draft: Create OpenAPI plugin Create OpenAPI plugin Aug 12, 2025
@geniegeist geniegeist marked this pull request as ready for review August 12, 2025 14:15
@charlie-haley
Copy link
Member

/test e2e

@github-actions
Copy link

E2E tests ❌ failed. View Run

@charlie-haley
Copy link
Member

/test e2e

@github-actions
Copy link

E2E tests ✅ passed. View Run

Copy link
Member

@charlie-haley charlie-haley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks again @geniegeist

@charlie-haley charlie-haley merged commit 0049ffa into marmotdata:main Aug 13, 2025
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants