Skip to content

feat(materials): add OPENAPI_SPEC, ASYNCAPI_SPEC, GRAPHQL_SPEC material types#3085

Merged
javirln merged 3 commits intochainloop-dev:mainfrom
javirln:javier/feat-openapi-asyncapi-graphql-material-types
May 4, 2026
Merged

feat(materials): add OPENAPI_SPEC, ASYNCAPI_SPEC, GRAPHQL_SPEC material types#3085
javirln merged 3 commits intochainloop-dev:mainfrom
javirln:javier/feat-openapi-asyncapi-graphql-material-types

Conversation

@javirln
Copy link
Copy Markdown
Member

@javirln javirln commented May 4, 2026

OpenAPI and AsyncAPI crafters validate specs against embedded JSON Schemas (with cascade version detection and noStrictValidation support). GraphQL crafter parses SDL using gqlparser. All three extract metadata annotations and support both JSON and YAML formats where applicable.

…al types

Add three new material types for Web API design validation (PSF-20-25).
OpenAPI and AsyncAPI crafters validate specs against embedded JSON Schemas
(with cascade version detection and noStrictValidation support). GraphQL
crafter parses SDL using gqlparser. All three extract metadata annotations
and support both JSON and YAML formats where applicable.

Assisted-by: Claude Code
Signed-off-by: Javier Rodriguez <javier@chainloop.dev>
@javirln javirln self-assigned this May 4, 2026
@javirln javirln requested review from jiparis and migmartri May 4, 2026 06:07
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

6 issues found across 42 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="internal/schemavalidators/external_schemas/openapi/openapi-3.1.schema.json">

<violation number="1" location="internal/schemavalidators/external_schemas/openapi/openapi-3.1.schema.json:967">
P1: The Link Object schema uses `body` instead of the OpenAPI-defined `server` property, causing incorrect validation behavior.</violation>
</file>

<file name="pkg/attestation/crafter/materials/asyncapi.go">

<violation number="1" location="pkg/attestation/crafter/materials/asyncapi.go:127">
P2: Selecting the first protocol from a map is non-deterministic; the annotated protocol can change between runs for the same AsyncAPI document.</violation>
</file>

<file name="pkg/attestation/crafter/materials/openapi.go">

<violation number="1" location="pkg/attestation/crafter/materials/openapi.go:108">
P2: `injectAnnotations` overwrites existing material annotations, removing metadata set earlier (such as `chainloop.material.size`).</violation>
</file>

<file name="pkg/attestation/crafter/materials/graphql_test.go">

<violation number="1" location="pkg/attestation/crafter/materials/graphql_test.go:115">
P2: Assertions in subtests are bound to the parent `*testing.T`; create assertion helpers per subtest (or pass `t` directly) so failures are attributed to the correct case.</violation>
</file>

<file name="pkg/attestation/crafter/materials/graphql.go">

<violation number="1" location="pkg/attestation/crafter/materials/graphql.go:76">
P2: Do not reinitialize `m.Annotations` here; it clears metadata set earlier (e.g., material size).</violation>
</file>

<file name="internal/schemavalidators/external_schemas/openapi/openapi-3.0.schema.json">

<violation number="1" location="internal/schemavalidators/external_schemas/openapi/openapi-3.0.schema.json:421">
P2: Link schema is missing the requirement that at least one of `operationId` or `operationRef` must be present, so invalid Link objects can pass validation.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Comment thread pkg/attestation/crafter/materials/asyncapi.go Outdated
Comment thread pkg/attestation/crafter/materials/openapi.go Outdated
Comment thread pkg/attestation/crafter/materials/graphql_test.go
Comment thread pkg/attestation/crafter/materials/graphql.go Outdated
… selection

Fix injectAnnotations in OpenAPI and GraphQL crafters to not overwrite
annotations set by uploadAndCraft (e.g. material size). Sort server names
in AsyncAPI crafter before selecting protocol to ensure deterministic
output across runs.

Assisted-by: Claude Code
Signed-off-by: Javier Rodriguez <javier@chainloop.dev>
Piskoo
Piskoo previously approved these changes May 4, 2026
Comment thread pkg/attestation/crafter/materials/openapi.go
Comment thread pkg/attestation/crafter/materials/asyncapi.go
… keys

API spec title and version are content metadata, not tool metadata.
Replace AnnotationToolNameKey/AnnotationToolVersionKey with dedicated
chainloop.material.api.name and chainloop.material.api.spec_version
annotation keys in OpenAPI and AsyncAPI crafters.

Assisted-by: Claude Code
Signed-off-by: Javier Rodriguez <javier@chainloop.dev>
Copy link
Copy Markdown
Member

@jiparis jiparis left a comment

Choose a reason for hiding this comment

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

looks good, thanks. check those Cubic reviews just in case.

@javirln javirln merged commit 623d06f into chainloop-dev:main May 4, 2026
18 of 19 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.

3 participants