$defs:
  AddressOneLine:
    type: object
    properties:
      one_line_address:
        type: string
        description: "Street name with inline house number, comma, then ZIP code and city name"
        pattern: '^([^\s,]+\s+)+\d+[a-zA-Z]?,\s*\d+\s+[^\s,]+(\s+[^\s,]+)*$'
        examples:
          - "Meine-Straße 1, 76136 Anytown"
    required:
      - one_line_address
    additionalProperties: true
    examples:
      - one_line_address: "Meine-Straße 1, 76136 Anytown"

  AddressTwoLines:
    type: object
    properties:
      street_and_housenumber:
        type: string
        description: "Street name with house number after whitespace"
        example: "Meine-Strasse 1"
        pattern: '^([^\s,]+\s+)+\d+[a-zA-Z]?$'
      zip_and_city:
        type: string
        description: "ZIP code and city name"
        example: "76136 Anytown"
        pattern: '^\d+\s+[^\s,]+(\s+[^\s,]+)*$'
    required:
      - street_and_housenumber
      - zip_and_city
    additionalProperties: true
    examples:
      - street_and_housenumber: "Meine-Straße 1"
        zip_and_city: "76136 Anytown"


  AddressList:
    type: array
    description: "List of addresses, either with inline or separated house number"
    items:
      anyOf:
        - { $ref: "#/$defs/AddressOneLine" }
        - { $ref: "#/$defs/AddressTwoLines" }
    minItems: 1
    example:
      - one_line_address: "Meine-Straße 1, 76136 Anytown"
      - street_and_housenumber: "Meine-Straße 1"
        zip_and_city: "76136 Anytown"

definitions:
  AddressOneLine:
    type: object
    properties:
      one_line_address:
        type: string
        description: "Street name with inline house number, comma, then ZIP code and city name"
        pattern: '^([^\s,]+\s+)+\d+[a-zA-Z]?,\s*\d+\s+[^\s,]+(\s+[^\s,]+)*$'
        examples:
          - "Meine-Straße 1, 76136 Anytown"
    required:
      - one_line_address
    additionalProperties: true
    examples:
      - one_line_address: "Meine-Straße 1, 76136 Anytown"

  AddressTwoLines:
    type: object
    properties:
      street_and_housenumber:
        type: string
        description: "Street name with house number after whitespace"
        example: "Meine-Strasse 1"
        pattern: '^([^\s,]+\s+)+\d+[a-zA-Z]?$'
      zip_and_city:
        type: string
        description: "ZIP code and city name"
        example: "76136 Anytown"
        pattern: '^\d+\s+[^\s,]+(\s+[^\s,]+)*$'
    required:
      - street_and_housenumber
      - zip_and_city
    additionalProperties: true
    examples:
      - street_and_housenumber: "Meine-Straße 1"
        zip_and_city: "76136 Anytown"


  AddressList:
    type: array
    description: "List of addresses, either with inline or separated house number"
    items:
      anyOf:
        - { $ref: "#/$defs/AddressOneLine" }
        - { $ref: "#/$defs/AddressTwoLines" }
    minItems: 1
    example:
      - one_line_address: "Meine-Straße 1, 76136 Anytown"
      - street_and_housenumber: "Meine-Straße 1"
        zip_and_city: "76136 Anytown"
