apache / apisix-dashboard

Dashboard for Apache APISIX
https://apisix.apache.org/
Apache License 2.0
1k stars 525 forks source link

[discuss] use YAML or pretty JSON to store the JSONSchema data #672

Open membphis opened 3 years ago

membphis commented 3 years ago

original comment: https://github.com/apache/apisix-dashboard/pull/651/files#r516345355

new way:

  1. YAML
  2. Pretty JSON

what do you think?

I think we can use YAML or formatted JSON style. The results need to be in order, which makes it easier to compare changes.

{
    "main": {
        "consumer": {
            "type": "object",
            "additionalProperties": false,
            "required": ["username"],
            "properties": {
                "labels": {
                    "description": "key/value pairs to specify attributes",
                    "maxProperties": 16,
                    "type": "object",
                    "patternProperties": {
                        ".*": {
                            "description": "value of label",
                            "maxLength": 64,
                            "type": "string",
                            "minLength": 1,
... ...
main:
  consumer:
    type: object
    additionalProperties: false
    required:
    - username
    properties:
      labels:
        description: key/value pairs to specify attributes
        maxProperties: 16
        type: object
        patternProperties:
          ".*":
            description: value of label
            maxLength: 64
            type: string
            minLength: 1
            pattern: "^[a-zA-Z0-9-_.]+$"
      username:
        type: string
        pattern: "^[a-zA-Z0-9_]+$"
        maxLength: 32
        minLength: 1
      update_time:
        type: integer
... ...
membphis commented 3 years ago

It seems that YAML is simpler and clearer. YAML +1

liuxiran commented 3 years ago

Eventually golang needs to return json to FE, so if we choose YAML, it seems that we also need a layer of data conversion, conver YAML to JSON.

membphis commented 3 years ago

Eventually golang needs to return json to FE, so if we choose YAML, it seems that we also need a layer of data conversion, convert YAML to JSON.

you are right. This file is used by manager-api and it will be automatically converted into JSON required by the front end.

juzhiyuan commented 3 years ago

Will this be implemented in 2.3?

membphis commented 3 years ago

I think the priority of this issue is not high, and it is recommended to remove it from the 2.3 milestone.