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

FR: option to produce MergePatch types readme.com can consume #33

Open
blakew opened this issue Jul 11, 2022 · 3 comments
Open

FR: option to produce MergePatch types readme.com can consume #33

blakew opened this issue Jul 11, 2022 · 3 comments

Comments

@blakew
Copy link

blakew commented Jul 11, 2022

Per readme.com support, they don't support type: null to clear field values. Instead, they require type: [null, "string"]

This ticket is a feature request to support this compound type in MergePatch where parameters can be cleared.

Example:

interfaces:
  Target:
     ...
     members:
       payload_map:
          required: false
          initializable: true
          mutable: true
          schema:
            type: object
            additionalProperties:
              type: string

Current output:

components:
  schemas:
    ...
    TargetMergePatch:
      type: object
      properties:
        payload_map:
          oneOf:
            - type: object
              additionalProperties:
                type: string
              description: Pass this value to overwrite the existing value.
              title: Overwrite
            - type: "null"       # unsupported by readme.com
              description: "Pass `null` to clear this field's existing value."
              title: Clear
      additionalProperties: false

Desired output:

components:
  schemas:
    ...
    TargetMergePatch:
      type: object
      properties:
        payload_map:
          oneOf:
            - type: object
              additionalProperties:
                type: string
              description: Pass this value to overwrite the existing value.
              title: Overwrite
            - type: [string, "null"]       # required by readme.com
              pattern: ^null$
              description: "Pass `null` to clear this field's existing value."
              title: Clear
      additionalProperties: false
@emk
Copy link
Contributor

emk commented Jul 11, 2022

Hmm, I think we'll probably need a more concrete example of a readme.com-compatible merge patch type, including one with a $ref property in it. :-(

@emk
Copy link
Contributor

emk commented Jul 11, 2022

Also, type: [string, "null"] broke a lot of OpenAPI tools about 6 months ago. The array version of type: [..] was extremely poorly supported. SO we'll need to look at compatibility.

@blakew
Copy link
Author

blakew commented Jul 11, 2022

ref example:

    Target:
      members:
        limit:
          required: false
          initializable: true
          mutable: true
          schema:
            $interface: "TargetLimit#SameAsInterface"

Current:

    TargetMergePatch:
      type: object
      properties:
        limit:
          oneOf:
            - $ref: "#/components/schemas/TargetLimitMergePatch"
            - type: "null"
              description: "Pass `null` to clear this field's existing value."
              title: Clear

Desired:

    TargetMergePatch:
      type: object
      properties:
        limit:
          oneOf:
            - $ref: "#/components/schemas/TargetLimitMergePatch"
            - type: [string, "null"]
              pattern: ^null$
              description: "Pass `null` to clear this field's existing value."
              title: Clear

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants