検索

記事
· 2025年11月10日 3m read

_spec para swagger-ui desde la clase de spec

Seguramente queríais usar la especificación OpenAPI (OAS) en formato JSON que utilizasteis para vuestra clase spec en el paquete iris-web-swagger-ui de IRIS.
La OAS generada por el método ##class(%REST.API).GetWebRESTApplication(...) es muy básica, sin descripciones de los parámetros ni de la estructura esperada de las respuestas.

Así que, después de crear vuestra aplicación REST a partir de una OAS, deberíais tener:

  • Una clase application.disp.cls generada
  • Una clase application.spec.cls (añadiremos una ruta hacia la especificación OpenAPI que se encuentra en la propiedad "XData OpenAPI")
  • Una clase application.impl.cls (solo implementaremos el método GetSpec)

Si instalasteis el paquete iris-web-swagger-ui (https://openexchange.intersystems.com/package/iris-web-swagger-ui), necesitáis un endpoint que devuelva la OAS.

Mi enfoque consiste en añadir una ruta hacia la OAS en la clase spec y aplicarla usando la propiedad "OpenAPI" de dicha clase spec. Esto os permitirá, por ejemplo, tener disponible para pruebas toda la estructura del OAS original.

En la clase de ejemplo del paquete iris-web-swagger-ui (Sample.PersonREST), hay una implementación del método SwaggerSpec que actualiza algunas propiedades para reflejar lo que está configurado en la Aplicación Web de IRIS. Si seguís este procedimiento, recomiendo actualizar directamente la OAS en la clase spec para proporcionar esa información y así centralizar la documentación de vuestra API (aunque siempre podéis actualizarla en el método GetSpec que os muestro como ejemplo).

Siguiendo el ejemplo de la clase Sample.PersonREST, la ruta será /_spec. Aunque existe un valor para la etiqueta "basePath", este será reemplazado por el nombre de la Aplicación Web de IRIS.

Class application.spec Extends %REST.Spec [ProcedureBlock]
{

XData OpenAPI [ MimeType = application/json ]
{
{
  ...
  "basePath":"/api/myapi",
  ...
  "paths":{
    "/_spec": {
      "get":{
        "operationId":"GetSpec",
        "description":"This OpenAPI Spec",
        "produces":[
          "application/json"
        ],
        "responses":{
          "200":{
            "description":"Successful operation"
            }
          }
        }
    }, 
...

Lo siguiente es pegar este código sencillo en la clase de implementación. Concretamente, después de compilar la clase spec, la clase impl tiene un nuevo método (GetSpec) que debe devolver un objeto dinámico (el comentario principal proviene de la OAS en la clase spec y de la etiqueta "description" del "get" en la ruta). Debéis reemplazar "application.spec" por la referencia a vuestra propia clase de aplicación.

/// This OpenAPI Spec
ClassMethod GetSpec() As %DynamicObject
{
    Set spec = {}.%FromJSON(##class(%Dictionary.CompiledXData).%OpenId("application.spec||OpenAPI").Data.Read())
    Set spec.basePath = %request.Application
    Return spec
}

¡Eso es todo!

Ahora id a vuestro iris-web-swagger-ui (en mi caso, http://localhost:52773/swagger-ui/index.html) y probad explorando en “http://localhost:52773/api/myapi/_spec” dentro del campo de navegación de swagger-ui.

Nota: definí una Aplicación Web llamada /api/myapi con “application.disp” como su “clase de despacho” (Dispatch class).

ディスカッション (0)1
続けるにはログインするか新規登録を行ってください
記事
· 2025年11月10日 2m read

FastJsonSchema: Native High-Performance JSON Validation for IRIS

FastJsonSchema: High-Performance JSON Validation in IRIS

Validating JSON data against JSON Schema is a common requirement for modern applications. FastJsonSchema brings this capability natively to InterSystems IRIS, combining speed, simplicity, and full schema compliance.

Unlike traditional validation approaches, FastJsonSchema generates native ObjectScript code from your JSON Schemas and compiles it directly to iris object code, enabling idiomatic performance without relying on external libraries or runtimes.

Why Use FastJsonSchema?

  • Native IRIS Code Generation – Compile your JSON Schema directly into ObjectScript and object code for lightning-fast execution.
  • High Performance – Fine-grained optimizations provide significant speed improvements, especially for repeated validations.
  • Detailed Validation – Validate at the property level with full adherence to JSON Schema rules.
  • Simple API – Compile schemas and validate JSON in just a few lines of code.
  • No External Dependencies – 100% native; no Python, Java, or other runtimes required.
  • Reusable Precompiled Schemas – Compile once, validate many times, reducing runtime overhead.

Supported JSON Schema Drafts

  • Draft-07

Getting Started

Compile a JSON Schema into native code:

Set sc = ##class(FastJsonSchema.Core).Compile(schema, schemaName)

Validate JSON data against a compiled schema:

Set sc = ##class(FastJsonSchema.Core).Validate(schemaName, pJSON)

Performance Tips

  • Compile Once, Use Many Times – Precompile schemas to object code to maximize speed.
  • Use Granular Schemas – Breaking complex JSON objects into smaller schemas improves validation efficiency.
  • Handle Exceptions Gracefully – Catch to manage invalid JSON cleanly.

With FastJsonSchema, Achieve the perfect balance of performance and flexibility — validating JSON data natively, efficiently, and with confidence.

1件の新着コメント
ディスカッション (1)1
続けるにはログインするか新規登録を行ってください
質問
· 2025年11月10日

CSPGatewayLatency Alert, what does it mean? How should be managed?

Hello, thanks for your time reading this question.

We are receiving each day, alerts from one of our four Production nodes. It always has the same text:

 

[InterSystems IRIS SEVERE ERROR gchciris4.canariasalud:ENSEMBLE] [Utility.Event] [SYSTEM MONITOR] CSPGatewayLatency(127.0.0.1:443) Alert: CSPGatewayLatency = 5001.304, 5001.233, 5000.964 (Max value is 2000).

 

We have looked for it in the documentation here:

https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY...

 

We thought it was related to the following paragraph:

"Server Response Timeout

The maximum number of seconds allowed for the target Caché server to respond to a request from the web server. The timeout refers to a period of no activity, so, for example, sending a line of HTML data every second for 10 hours does not cause a timeout. The minimum allowable value for this field is 5 seconds.

The value set here is the default for the system. If an Inherited Value is specified, the value came from the Default Parameters page. You may, however, set a different value on individual server-specific configurations or within the application itself.

Note that if you have an Apache server, you can also set this value using Timeout in the Apache http.conf file. The lower of these two values is triggered first."

 

 

However, we suppose that CSP Gateway Latency of maximum 2 seconds is not related to Server Response Timeout by default limited to 5 seconds.

 

We just want to understand the Node error. Could you please point to the documentation where it is explained?

 

We need to understand it prior to solve it.

 

We have also looke for "CSPGatewayLatency" using the forum search text area, but it does not pop up relevant results.

https://community.intersystems.com/smartsearch?search=CSPGatewayLatency

 

Could you please help us? Thank you so much.

 

We have also seen this example:

Update Default Parameter(s)

Kill newpars
Set newpars("Server_Response_Timeout")=30
Do gateway.SetDefaultParams(.newpars)

Found here: https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY...

 

And this old post:

https://community.intersystems.com/post/cache-monlbl-response-time-question

 

Could your help us, please? Thanks.

5 Comments
ディスカッション (5)3
続けるにはログインするか新規登録を行ってください
お知らせ
· 2025年11月9日

InterSystems 2025开发者创意大赛:让梦想落地

Hi开发者们!

鉴于去年首届大赛取得了巨大成功,我们决定再次举办这一赛事:

🏆InterSystems 2025开发者创意大赛:让梦想落地

您可以提交一个应用程序,实现InterSystems 创意门户中的创意,该创意应于本公告发布之前创建,其状态应为 Community Opportunity(社区共建机遇)Future Consideration(待研功能提案),您需要进行实际编程 😉

时间美国东部时间,2025 年 11 月 17 日至 12 月 7 日活动将延长至2025年12月14日! (项目提交时间延长至12月7日)

奖金12,000 美元

 

主题

在本次竞赛中,我们希望参赛者能够实现 InterSystems 创意门户网站中任意创建于本公告发布之前(美国东部时间2025年11月7日之前)、状态为Community Opportunity(社区共建机遇)Future Consideration(待研功能提案)的优秀创意。

基本要求:

  1. 应用程序或库必须功能完整且原创。不得简单导入或直接调用其他语言的现有库(C++除外,为IRIS创建接口需投入大量工作)。不得复制现有项目,不得包含任何专有代码。不得使用 InterSystems 或任何其他公司产品的逆向工程成果。请阅读我们的使用条款
  2. 只接受全新应用程序
  3. 该应用程序应在IRIS Community Edition 或 IRIS for Health Community Edition上运行。两者均可从 Evaluation site 下载主机(Mac、Windows)版本,或从InterSystems Container Registry 或 Community Containers 中拉取容器版:intersystemsdc/iris-community:latest 或 intersystemsdc/irishealth-community:latest
  4. 应用程序需为开源项目,并发布在GitHub或GitLab上。
  5. 应用程序的README文件需为英文,包含安装步骤,以及视频演示或/和应用工作原理的描述。
  6. 每位开发者最多提交三个作品。
  7. 可接受不同程序员/团队为实现同一想法而提交的不同应用程序。

注意。我们的专家将根据复杂性和实用性标准,对应用程序是否获准参赛拥有最终决定权。他们的决定为最终决定,不得上诉。

奖项设置

1. 专家提名奖(Experts Nomination)——获奖者由我们特别挑选的专家团选出:

🥇第一名 - 5,000 美元

🥈第二名 - 2,500 美元

🥉第三名 - 1,000 美元

🏅第四名 - 500 美元

🏅第五名 - 300 美元

🌟第 6-10 名 - 100 美元

2. 社区提名奖(Community Nomination)—— 获得总票数最多的应用程序:

🥇第一名 - 1,000 美元

🥈第二名 - 600 美元

🥉第三名 - 300 美元

🏅第四名 - 200 美元

🏅第五名 - 100 美元

❗ 若多名参赛者获得相同票数,则均视为获奖者,奖金由获奖者平分。
❗ 奖金仅发放给能验证身份的获奖者。如有疑问,组织方将联系参赛者要求提供额外信息。

谁可以参加?

开发者社区成员均可参加,InterSystems内部员工除外(InterSystems contractor员工可以参加)。还没有账号?现在来建一个!       

👥开发人员可以组队创建协作应用程序。一个团队允许 2 到 5 名开发人员。

请注意,要在您的README文件中标注您的团队成员(社区用户主页)。

重要截止日期:

🛠 应用程序开发和注册阶段:

  • 美国东部时间 2025 年 11 月 17 日(00:00):竞赛开始。
  • 美国东部时间 2025 年 12 月 7 日(23:59):提交截止日期。

投票阶段:

  • 美国东部时间 2025 年 12 月 8 日 (00:00):投票开始。
  • 美国东部时间 2025 年 12 月 14 日(23:59):投票结束。

注:在整个参赛期间(开发与投票期间),开发者可持续改进其应用程序

资源助力

✓ 示例应用程序:

✓ 我们建议从以下模板开始:

✓ 适用于 IRIS 和 Python 初学者:

✓ 面向使用 IRIS 和 ObjectScript 的初学者:

✓ 面向使用ObjectScript Package Manager (IPM) 的初学者:

✓ 如何向竞赛提交应用程序:

需要帮助?

加入 InterSystemsDiscord 服务器的竞赛频道,或在本帖评论区与我们交流。

我们迫不及待地想看到您的项目!祝好运 👍


参加本次竞赛即表示您同意此处列出的竞赛条款。请在参赛前仔细阅读这些条款。

 
ディスカッション (0)1
続けるにはログインするか新規登録を行ってください