Skip to content

v0.5.0

Choose a tag to compare

@github-actions github-actions released this 17 Oct 01:30
· 137 commits to main since this release

Added

  • OpenAPI documents. openapi.New(openapi.Options{...}) in InstalledApps serves an OpenAPI 3.1 document of every included route at /openapi.json (opt-in: nothing is served otherwise). openapi.Dev is the same app served only when TANGO_OPENAPI=1, so a deployed process exposes nothing unless it sets the variable. Each route is listed with its method, path, path parameters, name and a tag from its prefix. tango.Doc(tango.RouteDoc{...}) adds a summary, a request body, query parameters, responses and a bearer requirement, with schemas reflected from Go types (encoding/json tags, nested and recursive types, varchar=n as maxLength); a type can name its schema with SchemaName(). tango check fails and names a route whose documented types cannot be described. The accounts JSON endpoints document themselves; the admin's pages and the cookie-flow pages are hidden from the document. RouteRegistry.Described and tango.DescribedRoute expose the route table to tools. tango newproject now leaves a comment in project/project.go saying where to add it. See OpenAPI documentation.
  • tango openapi [-o file] prints or writes the document (the new -tango-openapi app-side flag, handled by DispatchFlags; DumpOpenAPI, OpenAPIProvider and ErrNoOpenAPI). The output is the same bytes on every run, and a failed run leaves an existing file untouched.
  • Swagger UI. openapi.Options{UI: swaggerui.New()} adds a browsable page at /docs/ from Swagger UI 5.17.14 embedded in the binary (Apache-2.0; no network request). It is the separate package openapi/swaggerui and adds about 1.7 MB to a binary that imports it.

Changed

  • Database connections are reused under load. database/sql keeps only 2 idle connections, so a server handling more than 2 requests at once closed and reopened a database connection on almost every request (measured: about 10,900 PostgreSQL sessions opened in one 15-second run of single-pet reads). ServeContext now raises the idle limit to 32 unless your app bounded the pool with SetMaxOpenConns. tango.WithDBPool(tango.DBPool{...}) sets the limits explicitly; tango.WithDBPool(tango.DBPool{}) restores the previous behavior. The number of open connections is unchanged (unlimited).

  • Foreign keys are not indexed unless you say so (guidance). A fk= column is not indexed by itself, so filtering or joining on it scans the table (measured: list on a 10,000-row table ran at about 1,300 requests a second without the index and about 3,200 with it). Write tango:"fk=Category,index" on foreign keys you filter or join on. Indexing foreign keys by default, as Django does, is planned for a later minor release; this entry is the notice.

Fixed

  • The admin no longer comes up silently empty. The admin builds its pages when it is installed, so a model registered by an app listed after admin.New never appeared in it. tango check (and -check) now fails and names those models, the tango newproject scaffold says to add apps above admin.New, and tango newapp repeats it when the project installs the admin. Move admin.New after your apps.