crashappsec / gql_schema_codegen

A module to generate Python typings from a GrapqhQL schema
MIT License
0 stars 1 forks source link

Generation is broken if comments are present #6

Open nettrino opened 1 year ago

nettrino commented 1 year ago

Multi-line comments brake code generation. For instance, the following snippet

enum CloudAccountStatus {
  """Cloud Account is successfully connected with connector"""
  CONNECTED

  """Error in connector"""
  ERROR

  """
  Connector is turned off, information about cloud account is updated to last scan
  """
  DISABLED

  """
  Wiz is scanning the connector for the first time, and validating the installation
  """
  INITIAL_SCANNING

  """
  Connection to service is successful but some permissions are missing causing a limited feature set
  """
  PARTIALLY_CONNECTED

  """All connectors to this cloud accounts were deleted"""
  DISCONNECTED

  """
  Wiz can detect cloud accounts that are not connected directly via connector by
  other references from configured connectors. When a cloud account was
  detected in that way a "Discovered" prefix will be added to it's name, and it's
  status will be DISCOVERED.
  """
  DISCOVERED
}

yields

class CloudAccountStatus(str, Enum):
    CONNECTED = "CONNECTED"
    ERROR = "ERROR"
    DISABLED = "DISABLED"
    INITIAL_SCANNING = "INITIAL_SCANNING"
    PARTIALLY_CONNECTED = "PARTIALLY_CONNECTED"
    DISCONNECTED = "DISCONNECTED"
    Wiz = "Wiz"
    other = "other"
    detected = "detected"
    status = "status"
    Select = "Select"
    of = "of"
    and = "and"
    set = "set"
    DEPRECATED = "DEPRECATED"
    e = "e"
    Inticates = "Inticates"
    If = "If"
    Indication = "Indication"
    Make = "Make"
    trigger = "trigger"
    In = "In"
    The = "The"
    iacMatchers = "iacMatchers"
    matcherTypes = "matcherTypes"

But if one removes all multiline comments (e.g., %s/\s*\("""\)\_.\{-}\1\n//) things are fine