Loopback 4 swagger 生成的过滤器似乎不起作用
Loopback 4 The swagger generated filters don't seem to work
我设置了一个连接到 mysql 数据库的基本模型和控制器。一切看起来都很好并且正在工作。
我的定义模型如下所示。
import { Entity, model, property } from '@loopback/repository';
@model({
settings: {
mysql: {
table: 'definition'
}
}
})
export class Definition extends Entity {
@property({
type: 'number',
id: true,
generated: true,
forceId: true,
required: false,
description: 'The unique identifier for a definition',
})
id: number;
@property({
type: 'string',
required: true,
})
name: string;
@property({
type: 'string',
required: true,
})
process_id: string;
constructor(data?: Partial<Definition>) {
super(data);
}
}
export interface DefinitionRelations {
// describe navigational properties here
}
export type DefinitionWithRelations = Definition & DefinitionRelations;
当我启动并 运行ning 并单击资源管理器对其进行测试时。
我单击 "Try it out" 获取/定义,唯一启用的可编辑字段是过滤器字段。
它重新填充了这样的值...
{
"where": {},
"fields": {
"id": true,
"name": true,
"process_id": true
},
"offset": 0,
"limit": 0,
"skip": 0,
"order": [
"string"
]
}
我必须清除它才能正常工作。当我 运行 它没有过滤器时,它 return 这些结果。
[
{
"id": 10,
"name": "Place Manual Payoff Order Process Config",
"process_id": "Process_PlaceManualPayoffOrderProcessConfig"
},
{
"id": 11,
"name": "test",
"process_id": "Test"
},
{
"id": 12,
"name": "test2",
"process_id": "test2"
}
]
我正在尝试将过滤器表达式仅用于 return 具有特定 process_id 字段的表达式。所以我将过滤器更改为如下所示。
{
"where": {"process_id": "test2"}
}
它仍然 return 结果相同。
[
{
"id": 10,
"name": "Place Manual Payoff Order Process Config",
"process_id": "Process_PlaceManualPayoffOrderProcessConfig"
},
{
"id": 11,
"name": "test",
"process_id": "Test"
},
{
"id": 12,
"name": "test2",
"process_id": "test2"
}
]
过滤器当前是否在 Loopback 4 中工作,还是我使用不正确?
编辑:如果我 post URL 字符串中的过滤器它们会起作用。似乎 openapi ui 没有将过滤器的那部分生成到 URL 字符串中。
It seems as though the openapi ui isn't generating that part of the filter Into the URL string.
是的,这是一个准确的描述。
OpenAPI 规范版本 3.x 未指定如何将 deeply-nested 值序列化为 URL 查询和 swagger-js
,库支持 swagger-ui
(为 LoopBack 的 REST API Explorer 提供支持),默默地忽略这些值。
此问题已报告并正在此处讨论:
我设置了一个连接到 mysql 数据库的基本模型和控制器。一切看起来都很好并且正在工作。
我的定义模型如下所示。
import { Entity, model, property } from '@loopback/repository';
@model({
settings: {
mysql: {
table: 'definition'
}
}
})
export class Definition extends Entity {
@property({
type: 'number',
id: true,
generated: true,
forceId: true,
required: false,
description: 'The unique identifier for a definition',
})
id: number;
@property({
type: 'string',
required: true,
})
name: string;
@property({
type: 'string',
required: true,
})
process_id: string;
constructor(data?: Partial<Definition>) {
super(data);
}
}
export interface DefinitionRelations {
// describe navigational properties here
}
export type DefinitionWithRelations = Definition & DefinitionRelations;
当我启动并 运行ning 并单击资源管理器对其进行测试时。
我单击 "Try it out" 获取/定义,唯一启用的可编辑字段是过滤器字段。
它重新填充了这样的值...
{
"where": {},
"fields": {
"id": true,
"name": true,
"process_id": true
},
"offset": 0,
"limit": 0,
"skip": 0,
"order": [
"string"
]
}
我必须清除它才能正常工作。当我 运行 它没有过滤器时,它 return 这些结果。
[
{
"id": 10,
"name": "Place Manual Payoff Order Process Config",
"process_id": "Process_PlaceManualPayoffOrderProcessConfig"
},
{
"id": 11,
"name": "test",
"process_id": "Test"
},
{
"id": 12,
"name": "test2",
"process_id": "test2"
}
]
我正在尝试将过滤器表达式仅用于 return 具有特定 process_id 字段的表达式。所以我将过滤器更改为如下所示。
{
"where": {"process_id": "test2"}
}
它仍然 return 结果相同。
[
{
"id": 10,
"name": "Place Manual Payoff Order Process Config",
"process_id": "Process_PlaceManualPayoffOrderProcessConfig"
},
{
"id": 11,
"name": "test",
"process_id": "Test"
},
{
"id": 12,
"name": "test2",
"process_id": "test2"
}
]
过滤器当前是否在 Loopback 4 中工作,还是我使用不正确?
编辑:如果我 post URL 字符串中的过滤器它们会起作用。似乎 openapi ui 没有将过滤器的那部分生成到 URL 字符串中。
It seems as though the openapi ui isn't generating that part of the filter Into the URL string.
是的,这是一个准确的描述。
OpenAPI 规范版本 3.x 未指定如何将 deeply-nested 值序列化为 URL 查询和 swagger-js
,库支持 swagger-ui
(为 LoopBack 的 REST API Explorer 提供支持),默默地忽略这些值。
此问题已报告并正在此处讨论: