Enforce Automatic schema validation for Spec-First REST implementations
1️⃣ Description of the idea
Enable automatic schema validation of incoming request bodies in REST APIs defined using Swagger/OpenAPI 2.0 when the request body is declared in the parameters section. The REST framework should automatically validate incoming JSON payloads against the specified schema and return a 422 Unprocessable Entity response if validation fails.
eg: Set status = ##class(%REST.Impl).SchemaValidation("json", schema, payload)
2️⃣ Who is the target audience?
API developers using OpenAPI 2.0 with InterSystems REST framework
Backend developers needing structured, contract-based validation
QA teams validating conformance to API specs
3️⃣ What problem does it solve?
Payloads are validated as defined in the OpenAPI spec
Invalid data is caught early
API behavior aligns with documentation
4️⃣ How does this impact the efficiency, stability, reliability, etc., of the product?
Efficiency: Reduces boilerplate code for validating API input/output
Stability: Ensures data conforms to expected structure before further processing
Reliability: Improves data quality and error handling
5️⃣ Provide a specific use case or scenario that illustrates how this idea could be used in practice
Validation must be implemented manually in ObjectScript, leading to redundant and error-prone code. With Native JSON Schema Validator The developer simply writes Clear, declarative validation. Safer, more predictable input handling and it helps Rapid API development with built-in schema support
Thank you for submitting the idea. The status has been changed to "Community Opportunity".
Stay tuned!
We are soon releasing an open source library for OpenAPI v3 support. Addressing this idea makes sense in the context of that project, so look for an announcement soon.