Skip to content

Proposal: add serverDefault and clientDefault keys to model spec #1789

@spacether

Description

@spacether

Proposal:

  • add serverDefault and clientDefault keys to openapi 3.X model spec
  • default becomes serverDefault
  • example/examples becomes clientExample, clientExamples

Reasons

  • Developer Confusion
    The current keys of default and example are ambiguous in their naming which creates developer confusion.
    People think that default values are defaults that the client will send to the server.
  • Spec Ambiguity
    The swagger 2.0 spec did not scope the default value to either the server or the client.
    The openapi 3.0 spec limits the scope of the default to server side, when the parameter is omitted by the client.
    Examples are not defined relative to a client or server reference. Implicitly, should we assume a client reference?
  • Spec Lacks Client Default
    In openapi 3.0 examples are not described as the client default, they are just samples.
    We are missing a location for a client default.
  • Some use cases require client defaults
    • an xml/json payload with a constant key/value pair. Though this is not the best design pattern, some apis do require this.
    • headers that must always have a constant value

General note about usage.
Per https://github.com/swagger-api/swagger-codegen
Number of Clients: 38
Number of Server Stubs: 14
So we have a significant number of clients which are using this spec, where client defaults are not defined. By the numbers it looks like the client codegen is used more than the server stubs, though this could just be indicative of there being more client languages vs server languages in use generally.

Example of Developer Confusion:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions