Skip to content

test: use Petstore spec from GitHub#2400

Merged
jamietanna merged 1 commit into
mainfrom
perf/petstore
Jun 6, 2026
Merged

test: use Petstore spec from GitHub#2400
jamietanna merged 1 commit into
mainfrom
perf/petstore

Conversation

@jamietanna

@jamietanna jamietanna commented Jun 6, 2026

Copy link
Copy Markdown
Member

We're seeing intermittent issues from the Petstore project such as:

error loading swagger spec in spec.yaml
: failed to load OpenAPI specification: error resolving reference
"https://petstore3.swagger.io/api/v3/openapi.json#/components/schemas/Pet":
error loading "https://petstore3.swagger.io/api/v3/openapi.json":
request returned status code 403

We can try and switch to the raw spec in GitHub to do this lookup, to
avoid hitting the Petstore API.

It's unclear if GitHub are going to be more performant, but it may help.

@jamietanna
jamietanna requested a review from a team as a code owner June 6, 2026 07:55
We're seeing intermittent issues from the Petstore project such as:

    error loading swagger spec in spec.yaml
    : failed to load OpenAPI specification: error resolving reference
    "https://petstore3.swagger.io/api/v3/openapi.json#/components/schemas/Pet":
    error loading "https://petstore3.swagger.io/api/v3/openapi.json":
    request returned status code 403

We can try and switch to the raw spec in GitHub to do this lookup, to
avoid hitting the Petstore API.

It's unclear if GitHub are going to be more performant, but it may help.
@jamietanna jamietanna changed the title test: don't use **??** test: use Petstore spec from GitHub Jun 6, 2026
@greptile-apps

greptile-apps Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR moves the externalref Petstore fixture away from the live Petstore API. The main changes are:

  • Updates the external $ref to use GitHub's raw Petstore spec.
  • Updates the matching import mapping for the Petstore package.
  • Regenerates the embedded externalref spec with the new remote URL.

Confidence Score: 4/5

This is close, but the external fixture should be pinned before merging.

  • The changed reference uses a moving upstream branch.
  • Future Petstore changes can make regeneration produce different code or fail without a repository change.
  • The current generated types still match the referenced Pet schema.

internal/test/externalref/spec.yaml and internal/test/externalref/externalref.cfg.yaml should use a pinned commit or a local vendored spec.

Important Files Changed

Filename Overview
internal/test/externalref/spec.yaml Changes the Petstore external reference to a raw GitHub branch URL.
internal/test/externalref/externalref.cfg.yaml Updates the import mapping to match the new Petstore URL.
internal/test/externalref/externalref.gen.go Regenerates the embedded OpenAPI fixture and raw-spec path mapping.

Reviews (1): Last reviewed commit: "test: use Petstore spec from GitHub" | Re-trigger Greptile

Comment on lines 14 to +15
pet:
$ref: https://petstore3.swagger.io/api/v3/openapi.json#/components/schemas/Pet
$ref: https://raw.githubusercontent.com/swagger-api/swagger-petstore/refs/heads/master/src/main/resources/openapi.yaml#/components/schemas/Pet

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Pin the external spec

This now points go generate at refs/heads/master, so the generated fixture depends on whatever Petstore has on that branch at generation time. If swagger-api changes components.schemas.Pet, this repository can start producing different generated code or failing generation without any local change. Pinning this to a commit or vendored file keeps the externalref test reproducible.

Suggested change
pet:
$ref: https://petstore3.swagger.io/api/v3/openapi.json#/components/schemas/Pet
$ref: https://raw.githubusercontent.com/swagger-api/swagger-petstore/refs/heads/master/src/main/resources/openapi.yaml#/components/schemas/Pet
pet:
$ref: https://raw.githubusercontent.com/swagger-api/swagger-petstore/<commit-sha>/src/main/resources/openapi.yaml#/components/schemas/Pet

@jamietanna
jamietanna force-pushed the perf/petstore branch 2 times, most recently from 1f54120 to d1bf1a4 Compare June 6, 2026 09:21
@mromaszewicz

Copy link
Copy Markdown
Member

I don't think that unit tests should be fetching stuff over the network at all. We can do that entirely with local files, but change looks good as-is.

This isn't a performance issue, HTTP/403 means we're tripping over some kind of auth or rate limiting

@jamietanna
jamietanna merged commit bfe9fa3 into main Jun 6, 2026
51 checks passed
@jamietanna
jamietanna deleted the perf/petstore branch June 6, 2026 20:09
@jamietanna

Copy link
Copy Markdown
Member Author

Yep, agreed that we shouldn't be hitting external services as part of our own builds (local or otherwise) and instead vendoring files

Relatedly: #1564

Re performance, I mean more that these calls to GitHub may be more likely to be slow and/or hit issues given their recent availability

@jamietanna jamietanna added the chore Any maintenance tasks that are regular, not as important to call out in the changelog label Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Any maintenance tasks that are regular, not as important to call out in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants