Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update openapi-generator #1292

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apiclient/typescript-fetch/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dmm-com/airone-apiclient-typescript-fetch",
"version": "0.0.19",
"version": "0.1.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the package 🙏

"description": "AirOne APIv2 client in TypeScript",
"main": "src/autogenerated/index.ts",
"scripts": {
Expand Down
11 changes: 2 additions & 9 deletions frontend/src/repository/AironeApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,10 @@
{
id,
aCL: {
id: id,
isPublic: isPublic,
defaultPermission: defaultPermission,
objtype: objectType,
aclSettings: aclSettings,
// readonly
name: "",
parent: null,
roles: [],
},
},
{
Expand Down Expand Up @@ -243,7 +238,6 @@
await this.entity.entityApiV2Create(
{
entityCreate: {
id: -1,
name: name,
note: note,
isToplevel: isToplevel,
Expand Down Expand Up @@ -272,7 +266,6 @@
{
id: id,
entityUpdate: {
id: id,
name: name,
note: note,
isToplevel: isToplevel,
Expand Down Expand Up @@ -364,7 +357,7 @@
attrs: AttributeData[]
): Promise<void> {
await this.entity.entityApiV2EntriesCreate(
{ entityId, entryCreate: { id: -1, name, attrs } },
{ entityId, entryCreate: { name, attrs } },
{
headers: {
"Content-Type": "application/json;charset=utf-8",
Expand All @@ -380,7 +373,7 @@
attrs: AttributeData[]
): Promise<void> {
await this.entry.entryApiV2Update(
{ id, entryUpdate: { id: id, name, attrs } },
{ id, entryUpdate: { name, attrs } },
{
headers: {
"Content-Type": "application/json;charset=utf-8",
Expand Down Expand Up @@ -525,10 +518,10 @@
const groupTrees = await this.group.groupApiV2GroupsTreeList();

// typing children here because API side type definition will break API client generation.
const toTyped = (groupTree: { [key: string]: any }): GroupTree => ({

Check warning on line 521 in frontend/src/repository/AironeApiClient.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
id: groupTree["id"],
name: groupTree["name"],
children: groupTree["children"].map((child: { [key: string]: any }) =>

Check warning on line 524 in frontend/src/repository/AironeApiClient.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
toTyped(child)
),
});
Expand All @@ -536,7 +529,7 @@
return groupTrees.map((groupTree) => ({
id: groupTree.id,
name: groupTree.name,
children: groupTree.children.map((child: { [key: string]: any }) =>

Check warning on line 532 in frontend/src/repository/AironeApiClient.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
toTyped(child)
),
}));
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"zod": "^3.22.4"
},
"dependencies": {
"@dmm-com/airone-apiclient-typescript-fetch": "^0.0.19",
"@dmm-com/airone-apiclient-typescript-fetch": "^0.1.0",
"@dnd-kit/core": "^6.1.0",
"@dnd-kit/modifiers": "^7.0.0",
"@dnd-kit/sortable": "^8.0.0",
Expand Down
5 changes: 5 additions & 0 deletions role/api_v2/serializers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from collections import OrderedDict

from drf_spectacular.utils import extend_schema_field
from rest_framework import serializers

from airone.lib.drf import RequiredParameterError
Expand Down Expand Up @@ -50,15 +51,19 @@ class Meta:
def get_filtered_data(self, obj, attribute, serializer):
return serializer(getattr(obj, attribute).filter(is_active=True), many=True).data

@extend_schema_field(RoleUserSerializer(many=True))
def get_users(self, obj):
return self.get_filtered_data(obj, "users", RoleUserSerializer)

@extend_schema_field(RoleUserSerializer(many=True))
def get_admin_users(self, obj):
return self.get_filtered_data(obj, "admin_users", RoleUserSerializer)

@extend_schema_field(RoleGroupSerializer(many=True))
def get_groups(self, obj):
return self.get_filtered_data(obj, "groups", RoleGroupSerializer)

@extend_schema_field(RoleGroupSerializer(many=True))
def get_admin_groups(self, obj):
return self.get_filtered_data(obj, "admin_groups", RoleGroupSerializer)

Expand Down
2 changes: 1 addition & 1 deletion tools/generate_client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -u

OPENAPI_GENERATOR_VERSION=v6.6.0
OPENAPI_GENERATOR_VERSION=v7.8.0
dst=${1:-frontend/src/apiclient/autogenerated}

# Check if "--docker" is passed as an argument
Expand Down
Loading