apple / swift-openapi-generator

Generate Swift client and server code from an OpenAPI document.
https://swiftpackageindex.com/apple/swift-openapi-generator/documentation
Apache License 2.0
1.21k stars 87 forks source link

Support schemas.type: string, format: uri generates URL property not String #560

Closed zunda-pixel closed 1 month ago

zunda-pixel commented 1 month ago

Motivation

Macro generates String property from this openapi.yaml Please change to URL property

components:
  schemas:
    Sample:
      name: link
      type: string
      format: uri
struct Sample {
  var link: String
}

Proposed solution

struct Sample {
  var link: URL
}
czechboy0 commented 1 month ago

Note that doing this by default would be an API-breaking change.

But I think it'd be reasonable to add a feature allowing adopters to customize some format strings and which types they should be generated as. If someone wants to design that feature and open a PR, we'll gladly help with review/feedback etc.

simonjbeaumont commented 1 month ago

Related to #514?

czechboy0 commented 1 month ago

Indeed, this is a duplicate. Let's centralize the discussion in that issue.