Skip to content

Microservice should cache its OpenAPI document instead of regenerating it on every admin/docs request #4742

Description

@allister-beamable

Problem

A C# microservice generates its OpenAPI document by reflecting over all of its registered types (routes plus request/response schemas) to build the schema set. This generation runs in full on every GET admin/docs request. On CPU-constrained instances, repeated polling of admin/docs produces repeated full reflection scans and adds significant, avoidable CPU load.

Expected

The OpenAPI document cannot change over the lifetime of a running microservice instance -- its routes and types are fixed at build time. After the document is generated once (at or after boot), admin/docs should return an identical, cached document without re-running the reflection scan.

Actual

Each admin/docs request re-runs the full reflection walk and rebuilds the document from scratch. Observed in production: one complete reflection pass over the service's schema types (hundreds of types) per request, i.e. one CPU-expensive scan for every hit. A client or probe polling admin/docs therefore drives one full scan per poll, which is enough to be a meaningful load on a small instance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions