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

use apollo openapi create properties file, can not create explanatory note #5095

Closed
pengbiaobeyond opened this issue Feb 20, 2024 · 27 comments
Closed
Labels

Comments

@pengbiaobeyond
Copy link

use apollo openapi create properties file, can not create explanatory note
使用apollo的openapi创建properties配置文件,不能创建注释
image
zhe这里的备注只存放在库里,并不是文件中的注释信息

Copy link

dosubot bot commented Feb 20, 2024

🤖

嘿,@pengbiaobeyond!很高兴再次见到你,希望你一切都好!

根据我对Apollo的理解,Apollo的OpenAPI在创建properties配置文件时,不支持在文件中创建注释。这是因为Apollo的设计理念是将配置中心视为一个数据库,而不是一个文件系统。因此,所有的配置项(包括注释)都存储在数据库中,而不是文件中。

在Apollo中,你可以为每个配置项添加注释,这些注释将存储在数据库中,而不是properties文件中。当你通过Apollo的OpenAPI获取配置时,你可以获取到这些注释,但是它们不会出现在properties文件中。

如果你需要在properties文件中添加注释,你可能需要在获取配置后,自行将注释添加到文件中。但请注意,这可能会使得配置的管理变得更加复杂,因为你需要同时管理数据库中的注释和文件中的注释。

希望这个解答能帮助到你。如果你有更多的问题,欢迎继续提问。

Sources

About Dosu

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@pengbiaobeyond
Copy link
Author

Hope to receive a manual reply

@pengbiaobeyond
Copy link
Author

希望老师帮忙确认下,是否是上边的解释,否则机器人回复心里没底

@BlackBear2003
Copy link
Member

是存在数据库里的,ui上的文本里面也是通过读数据库来渲染的 🤔️

@pengbiaobeyond
Copy link
Author

ui上的文本里边的注释在数据库中item表中的数据是key、value字段的值是空,comment字段的值是注释;
但是通过openApi,只能创建key、value有值,comment是key和value的备注,不是注释,ui无法渲染

@pengbiaobeyond
Copy link
Author

如果存在注释的话,注释和key、value在item表里是两条数据

@pengbiaobeyond
Copy link
Author

但是openApi只能创建一条数据

@pengbiaobeyond
Copy link
Author

无法渲染注释

@pengbiaobeyond
Copy link
Author

只有下图的红框的数据才可以渲染成注释,第一条数据是第二条数据的注释

@pengbiaobeyond
Copy link
Author

1708430375997

@pengbiaobeyond
Copy link
Author

但是openApi创建的properties配置是这样的,所以无法渲染
1708430483805

@BlackBear2003
Copy link
Member

找了下代码,确实是这样

             function parsePropertiesText(namespace) {
                var result = "";
                var itemCnt = 0;
                namespace.items.forEach(function (item) {
                    //deleted key
                    if (item.isDeleted) {
                        return;
                    }
                    if (item.item.key) {
                        //use string \n to display as new line
                        var itemValue = item.item.value.replace(/\n/g, "\\n");

                        result +=
                            item.item.key + " = " + itemValue + "\n";
                    } else {
                        result += item.item.comment + "\n";
                    }
                    itemCnt++;
                });

                namespace.itemCnt = itemCnt;
                return result;
            }

@pengbiaobeyond
Copy link
Author

所以说openApi目前是无法支持给properties配置文件添加注释的对吧

@BlackBear2003
Copy link
Member

BlackBear2003 commented Feb 20, 2024

表格里面可以看到,但是文本里面好像是渲染不出来

@pengbiaobeyond
Copy link
Author

恩恩,就是数据库表里可以看到,只是无法渲染到页面上对吧

@BlackBear2003
Copy link
Member

可以等明天maintainer大佬来给个准确的回复 😳

@pengbiaobeyond
Copy link
Author

好的,辛苦您明天帮我问下,谢谢

@pengbiaobeyond
Copy link
Author

麻烦大佬今天帮忙看下

@pengbiaobeyond
Copy link
Author

辛苦老师帮忙看下,拜托

@BlackBear2003
Copy link
Member

我认为你的想法是对的,但我并不是官方人员,没法给你准确的回复 😂

@nobodyiam
Copy link
Member

properties 文件的注释是在内容里面的,如

# comment 1
key1 = value1
# comment 2
key2 = value2

通过文本模式可以看到,不过请注意这个注释在表格模式是看不到的(设计如此)
image

@pengbiaobeyond
Copy link
Author

我明白,但是通过openapi去添加properties配置文件中的内容时,是无法添加注释的

@pengbiaobeyond
Copy link
Author

您上边的截图其实在数据库item表中是四条数据,但是openApi无法创建注释数据,
image

@nobodyiam
Copy link
Member

如果是单个配置的话是可以的,下面是我的测试代码和结果

  @Test
  public void testCreate() {
    OpenItemDTO itemDTO = new OpenItemDTO();
    itemDTO.setKey("testKey");
    itemDTO.setValue("testValue");
    itemDTO.setComment("测试注释");
    itemDTO.setDataChangeCreatedBy(operator);

    OpenItemDTO result = client.createItem(appId, env, null, null, itemDTO);

    System.out.println(result);
  }

image

@pengbiaobeyond
Copy link
Author

好的,明白了,谢谢

Copy link

stale bot commented Mar 30, 2024

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days unless it is tagged "help wanted" or other activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Mar 30, 2024
Copy link

stale bot commented Apr 18, 2024

This issue has been automatically closed because it has not had activity in the last 7 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted". Thank you for your contributions.

@stale stale bot closed this as completed Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants