Skip to content

Swagger UI that renders well: structured OpenAPI + UseEzODataSwaggerUI() (1.0.7) - #7

Merged
rvegajr merged 3 commits into
mainfrom
feat/openapi-polish
Sep 30, 2026
Merged

rvegajr merged 3 commits into
mainfrom
feat/openapi-polish

Conversation

@rvegajr

@rvegajr rvegajr commented Sep 30, 2026

Copy link
Copy Markdown
Member

Why

In Swagger UI the generated documents rendered poorly:

  • every operation sat under one "default" group
  • summaries read "Create a customers" and "Get a customers by key"
  • by-key operations had no {id} input, so "Try it out" sent a literal {id}
  • the header was bare

OpenAPI documents (EzOdata.Docs)

  • One tag per table, with a description such as Table · 5 columns · key: id · related: orders. Every operation is tagged.
  • Correct summaries: Query customers, Create a row in customers, Get a row from customers by key, and so on. Operations also get operationIds (customers_list, …).
  • Path parameters declared on by-key paths, one per key column for composite keys.
  • REST envelope documented as resource (what REST returns), and REST create as 201.
  • info.description: a short query guide whose examples come from the service's real columns. Per-operation hints include the $expand targets.
  • GeneratorVersion 1.1, which refreshes ETag-cached documents.

app.UseEzODataSwaggerUI() (EzOdata.AspNetCore)

  • One line gives a Swagger UI at /swagger listing every declared service on every mapped API, discovered at request time, so the order of calls doesn't matter.
  • "Try it out" is on by default, with a table filter, request timings and deep links. The schemas section is hidden, since each operation already shows its schemas.
  • ez-odata styling uses the admin console palette. The stylesheet URL is versioned, so it's never stale after an upgrade, and the layout works on phone widths.
  • Built on Swashbuckle.AspNetCore.SwaggerUI's embedded assets, so it works offline.

Verified in a real browser

Tested on a two-database sample (shop and warehouse, OData and REST):

  • all four documents are auto-listed
  • OData GET /products(2) → 200
  • REST documents show REST-syntax examples
  • at 390 px the page has no horizontal scroll

Tests

  • OpenApiDocsTests.Openapi_is_structured_for_swagger_ui and Rest_openapi_documents_the_resource_envelope: real PostgreSQL.
  • EmbeddedHostTests.Swagger_ui_lists_every_service_on_every_mapped_api.
  • The existing path and schema-name assertions are unchanged.

- One tag per table (with columns, key, related tables), and every operation
  tagged, so Swagger UI groups by table instead of one 'default' list.
- Summaries read correctly ('Create a row in customers', not 'Create a
  customers'); operationIds (customers_list, ...).
- By-key paths declare their path parameters: 'Try it out' now has an {id}
  input instead of sending a literal {id}.
- REST list responses documented under 'resource' (what REST returns);
  REST create documented as 201.
- info.description: a short guide to the query options, with examples built
  from the service's real columns; per-operation hints incl. $expand targets.
- GeneratorVersion 1.1 (refreshes ETag-cached documents).
…line

Serves Swagger UI (default /swagger) listing every service declared with
AddService on every API mapped with MapEzOData/MapEzODataRest, discovered at
request time. Try it out on by default, table filter, request timings, deep
links, schemas section hidden, and ez-odata styling (versioned stylesheet,
responsive). Uses Swashbuckle.AspNetCore.SwaggerUI's embedded assets, so it
works offline.
@rvegajr
rvegajr merged commit ad685ed into main Sep 30, 2026
4 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.

1 participant