Skip to content

Releases: responsibleapi/responsible

@responsibleapi/ts v1.2.0

Choose a tag to compare

@meoyawn meoyawn released this 14 Jul 23:51

Explicit object strictness

OpenAPI permits extra object properties by default when additionalProperties is omitted. Some downstream validators follow that behavior. In particular, Go services using kin-openapi may accept unknown fields where a strict API would reject them. Other validators and generators may behave the same way.

@responsibleapi/ts now provides one document-wide switch for explicit object strictness:

responsibleAPI({
  options: {
    objectAdditionalProperties: false,
  },
  partialDoc: { /* ... */ },
  routes: { /* ... */ },
})
  • false emits additionalProperties: false for every schema created with object(), including nested objects and objects used in requests, responses, components, arrays, unions, and nullable schemas.
  • true explicitly keeps every object() schema open.
  • Omitting options preserves existing output exactly.

This makes generated OpenAPI documents reliably strict across downstream tooling without changing every object schema individually. dict() remains a typed dictionary and is not closed by this switch.

@responsibleapi/ts v1.1.0

Choose a tag to compare

@meoyawn meoyawn released this 15 Jul 00:02

Typed Server-Sent Events

OpenAPI 3.2 can describe each event in a text/event-stream response with itemSchema. @responsibleapi/ts now generates that output directly:

200: resp({
  body: {
    "text/event-stream": {
      itemSchema: object({
        event: string({ const: "message" }),
        data: string(),
      }),
    },
  },
})

The generated OpenAPI document places the event schema at content["text/event-stream"].itemSchema. Downstream documentation, validators, and generators can understand each streamed event instead of treating the response as an untyped stream.

Any ResponsibleAPI schema can be used as the item schema, including named schemas and unions. This output requires an OpenAPI 3.2 document.