Azure / data-api-builder

Data API builder provides modern REST and GraphQL endpoints to your Azure Databases and on-prem stores.
https://aka.ms/dab/docs
MIT License
854 stars 176 forks source link

Hot Reload of the OpenApi Document #1869

Open aaronburtle opened 10 months ago

aaronburtle commented 10 months ago

The Open Api Document is generated on startup, and so to properly update the doc when a hot reload occurs we need to trigger that create document call as part of the hot reload process. This issues covers implementation of that plus the other changes needed to make sure that the open api docs properly update during a hot reload.

seantleonard commented 6 months ago

Moving this + hot reload related tasks to post GA -> tracking via 1.2rc milestone.

seantleonard commented 4 months ago

Current OpenApiDocumentor implementation has function CreateDocument() which has this preliminary check

            if (_openApiDocument is not null)
            {
                throw new DataApiBuilderException(
                    message: DOCUMENT_ALREADY_GENERATED_ERROR,
                    statusCode: HttpStatusCode.Conflict,
                    subStatusCode: DataApiBuilderException.SubStatusCodes.OpenApiDocumentAlreadyExists);
            }

Enabling hot reload involes removing this check and rethinking what situations necessitate calling OpenApiDocumentor::CreateDocument() again.

At first glance, adding a hot reload function directly to IOpenApiDocumentor or OpenApiDocumentor is not appropriate. Another service should call openapidocumentor.CreateDocument() when new config comes in.

Consider: