Skip to content

Schema descriptions with newlines  #333

@gdavison

Description

@gdavison

Schema descriptions with \n or \r\n are split, but the // is only applied to the first line. Descriptions on properties are handled correctly.

For example, the following fragment in JSON

      "Destiny.Entities.Items.DestinyItemSocketState": {
        "type": "object",
        "properties": {
          ...
          "isEnabled": {
            "type": "boolean",
            "description": "Even if a plug is inserted, it doesn't mean it's enabled.\r\nThis flag indicates whether the plug is active and providing its benefits."
          },
          ...
        },
        "description": "The status of a given item's socket. (which plug is inserted, if any: whether it is enabled, what \"reusable\" plugs can be inserted, etc...)\r\nIf I had it to do over, this would probably have a DestinyItemPlug representing the inserted item instead of most of these properties. :shrug:"
      },

generates the following Go code

// The status of a given item's socket. (which plug is inserted, if any: whether it is enabled, what "reusable" plugs can be inserted, etc...)
If I had it to do over, this would probably have a DestinyItemPlug representing the inserted item instead of most of these properties. :shrug:
type DestinyEntitiesItemsDestinyItemSocketState  struct {

    ...

// Even if a plug is inserted, it doesn't mean it's enabled.
// This flag indicates whether the plug is active and providing its benefits.
    IsEnabled *bool `json:"isEnabled,omitempty"`

    ...
}

The property handling code call the function StringToGoComment to handle this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions