Skip to content

Commit

Permalink
merge dev to main (v2.7.0) (#1782)
Browse files Browse the repository at this point in the history
  • Loading branch information
ymc9 authored Oct 16, 2024
2 parents be8c1c4 + 4fc4cf7 commit 4e80c29
Show file tree
Hide file tree
Showing 141 changed files with 18,645 additions and 3,119 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zenstack-monorepo",
"version": "2.6.2",
"version": "2.7.0",
"description": "",
"scripts": {
"build": "pnpm -r build",
Expand Down
2 changes: 1 addition & 1 deletion packages/ide/jetbrains/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = "dev.zenstack"
version = "2.6.2"
version = "2.7.0"

repositories {
mavenCentral()
Expand Down
2 changes: 1 addition & 1 deletion packages/ide/jetbrains/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jetbrains",
"version": "2.6.2",
"version": "2.7.0",
"displayName": "ZenStack JetBrains IDE Plugin",
"description": "ZenStack JetBrains IDE plugin",
"homepage": "https://zenstack.dev",
Expand Down
2 changes: 1 addition & 1 deletion packages/language/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/language",
"version": "2.6.2",
"version": "2.7.0",
"displayName": "ZenStack modeling language compiler",
"description": "ZenStack modeling language compiler",
"homepage": "https://zenstack.dev",
Expand Down
2 changes: 1 addition & 1 deletion packages/misc/redwood/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/redwood",
"displayName": "ZenStack RedwoodJS Integration",
"version": "2.6.2",
"version": "2.7.0",
"description": "CLI and runtime for integrating ZenStack with RedwoodJS projects.",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/openapi/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/openapi",
"displayName": "ZenStack Plugin and Runtime for OpenAPI",
"version": "2.6.2",
"version": "2.7.0",
"description": "ZenStack plugin and runtime supporting OpenAPI",
"main": "index.js",
"repository": {
Expand Down
16 changes: 12 additions & 4 deletions packages/plugins/openapi/src/rest-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,14 +409,17 @@ export class RESTfulOpenAPIGenerator extends OpenAPIGeneratorBase {
private generateFilterParameters(model: DataModel) {
const result: OAPI.ParameterObject[] = [];

const hasMultipleIds = model.fields.filter((f) => isIdField(f)).length > 1;

for (const field of model.fields) {
if (isForeignKeyField(field)) {
// no filtering with foreign keys because one can filter
// directly on the relationship
continue;
}

if (isIdField(field)) {
// For multiple ids, make each id field filterable like a regular field
if (isIdField(field) && !hasMultipleIds) {
// id filter
result.push(this.makeFilterParameter(field, 'id', 'Id filter'));
continue;
Expand Down Expand Up @@ -843,7 +846,9 @@ export class RESTfulOpenAPIGenerator extends OpenAPIGeneratorBase {
}

private generateModelEntity(model: DataModel, mode: 'read' | 'create' | 'update'): OAPI.SchemaObject {
const fields = model.fields.filter((f) => !isIdField(f));
const idFields = model.fields.filter((f) => isIdField(f));
// For compound ids, each component is also exposed as a separate field
const fields = idFields.length > 1 ? model.fields : model.fields.filter((f) => !isIdField(f));

const attributes: Record<string, OAPI.SchemaObject> = {};
const relationships: Record<string, OAPI.ReferenceObject | OAPI.SchemaObject> = {};
Expand All @@ -869,6 +874,9 @@ export class RESTfulOpenAPIGenerator extends OpenAPIGeneratorBase {
!(isDataModel(field.$resolvedType?.decl) && field.type.array)
) {
required.push(field.name);
} else if (mode === 'read') {
// Until we support sparse fieldsets, all fields are required for read operations
required.push(field.name);
}
}
}
Expand All @@ -886,8 +894,8 @@ export class RESTfulOpenAPIGenerator extends OpenAPIGeneratorBase {

if (mode === 'create') {
// 'id' is required if there's no default value
const idField = model.fields.find((f) => isIdField(f));
if (idField && !hasAttribute(idField, '@default')) {
const idFields = model.fields.filter((f) => isIdField(f));
if (idFields.length && idFields.every((f) => !hasAttribute(f, '@default'))) {
properties = { id: { type: 'string' }, ...properties };
toplevelRequired.unshift('id');
}
Expand Down
Loading

0 comments on commit 4e80c29

Please sign in to comment.