kcl-lang/kcl-openapi

wrong indenting when generate from schema/attribute description to docstring

amyXia1994 opened this issue · 0 comments

Bug Report

when translating k8s openapi to KCL models, the attribute description may contain line break

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. save following code as oai.json
{
   "definitions": {
      "io.k8s.api.admissionregistration.v1.MutatingWebhook": {
         "description": "MutatingWebhook describes an admission webhook and the resources and operations it applies to.",
         "properties": {
            "matchPolicy": {
               "description": "matchPolicy defines how the \"rules\" list is used to match incoming requests. Allowed values are \"Exact\" or \"Equivalent\".\n\n- Exact: match a request only if it exactly matches a specified rule. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, but \"rules\" only included `apiGroups:[\"apps\"], apiVersions:[\"v1\"], resources: [\"deployments\"]`, a request to apps/v1beta1 or extensions/v1beta1 would not be sent to the webhook.\n\n- Equivalent: match a request if modifies a resource listed in rules, even via another API group or version. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, and \"rules\" only included `apiGroups:[\"apps\"], apiVersions:[\"v1\"], resources: [\"deployments\"]`, a request to apps/v1beta1 or extensions/v1beta1 would be converted to apps/v1 and sent to the webhook.\n\nDefaults to \"Equivalent\"",
               "type": "string"
            }
         }
      }
   },
   "info": {
      "title": "Kubernetes",
      "version": "unversioned"
   },
   "paths": {},
   "swagger": "2.0"
}
  1. run kcl-openapi generate model -f oai.json -t output
  2. run cat output/models/io_k8s_api_admissionregistration_v1_mutating_webhook.k

2. What did you expect to see? (Required)

"""
This file was generated by the KCL auto-gen tool. DO NOT EDIT.
Editing this file might prove futile when you re-run the KCL auto-gen generate command.
"""


schema MutatingWebhook:
    """ MutatingWebhook describes an admission webhook and the resources and operations it applies to.

    Attributes
    ----------
    matchPolicy : str, default is Undefined, optional
        matchPolicy defines how the "rules" list is used to match incoming requests. Allowed values are "Exact" or "Equivalent".
 
        - Exact: match a request only if it exactly matches a specified rule. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, but "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`, a request to apps/v1beta1 or extensions/v1beta1 would not be sent to the webhook.
 
        - Equivalent: match a request if modifies a resource listed in rules, even via another API group or version. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, and "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`, a request to apps/v1beta1 or extensions/v1beta1 would be converted to apps/v1 and sent to the webhook.
        Defaults to "Equivalent"
    """


    matchPolicy?: str



3. What did you see instead (Required)

"""
This file was generated by the KCL auto-gen tool. DO NOT EDIT.
Editing this file might prove futile when you re-run the KCL auto-gen generate command.
"""


schema MutatingWebhook:
    """ MutatingWebhook describes an admission webhook and the resources and operations it applies to.

    Attributes
    ----------
    matchPolicy : str, default is Undefined, optional
         matchPolicy defines how the "rules" list is used to match incoming requests. Allowed values are "Exact" or "Equivalent".
 
 - Exact: match a request only if it exactly matches a specified rule. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, but "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`, a request to apps/v1beta1 or extensions/v1beta1 would not be sent to the webhook.
 
 - Equivalent: match a request if modifies a resource listed in rules, even via another API group or version. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, and "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`, a request to apps/v1beta1 or extensions/v1beta1 would be converted to apps/v1 and sent to the webhook.
 Defaults to "Equivalent"
    """


    matchPolicy?: str



4. What is your KusionStack components version? (Required)

--