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

Compiler error for generated code related to binary content encoding #701

Open
MahdiBM opened this issue Dec 13, 2024 · 0 comments
Open
Labels
kind/bug Feature doesn't work as expected. status/triage Collecting information required to triage the issue.

Comments

@MahdiBM
Copy link
Contributor

MahdiBM commented Dec 13, 2024

Description

Compiler error for generated code related to binary content encoding.
See below for a quick repro.

the error is:

API/Sources/OpenAPI/GeneratedSources/Types.swift:27:24: error: type 'Components.Schemas.CategoryResponse' does not conform to protocol 'Decodable'
25 |     package enum Schemas {
26 |         /// - Remark: Generated from `#/components/schemas/CategoryResponse`.
27 |         package struct CategoryResponse: Codable, Hashable, Sendable {
   |                        `- error: type 'Components.Schemas.CategoryResponse' does not conform to protocol 'Decodable'
28 |             /// The image file for the category (supported formats: jpg, png, webp)
29 |             ///
30 |             /// - Remark: Generated from `#/components/schemas/CategoryResponse/image`.
31 |             package var image: OpenAPIRuntime.HTTPBody?
   |                         `- note: cannot automatically synthesize 'Decodable' because 'OpenAPIRuntime.HTTPBody?' does not conform to 'Decodable'
32 |             /// Creates a new `CategoryResponse`.
33 |             ///

Swift.Decodable:2:5: note: protocol requires initializer 'init(from:)' with type 'Decodable'
1 | public protocol Decodable {
2 |     init(from decoder: any Decoder) throws
  |     `- note: protocol requires initializer 'init(from:)' with type 'Decodable'
3 | }

API/Sources/OpenAPI/GeneratedSources/Types.swift:27:24: error: type 'Components.Schemas.CategoryResponse' does not conform to protocol 'Encodable'
25 |     package enum Schemas {
26 |         /// - Remark: Generated from `#/components/schemas/CategoryResponse`.
27 |         package struct CategoryResponse: Codable, Hashable, Sendable {
   |                        `- error: type 'Components.Schemas.CategoryResponse' does not conform to protocol 'Encodable'
28 |             /// The image file for the category (supported formats: jpg, png, webp)
29 |             ///
30 |             /// - Remark: Generated from `#/components/schemas/CategoryResponse/image`.
31 |             package var image: OpenAPIRuntime.HTTPBody?
   |                         `- note: cannot automatically synthesize 'Encodable' because 'OpenAPIRuntime.HTTPBody?' does not conform to 'Encodable'
32 |             /// Creates a new `CategoryResponse`.
33 |             ///

Swift.Encodable:2:10: note: protocol requires function 'encode(to:)' with type 'Encodable'
1 | public protocol Encodable {
2 |     func encode(to encoder: any Encoder) throws
  |          `- note: protocol requires function 'encode(to:)' with type 'Encodable'
3 | }

Reproduction

openapi: "3.1.0"
info:
  title: My API
  version: 1.0.0
components:
  schemas:
    CategoryResponse:
      type: object
      properties:
        image:
          title: Image
          type: string
          contentEncoding: binary
          description: "The image file for the category (supported formats: jpg, png, webp)"

Package version(s)

generator 1.3.0
runtime 1.5.0

Expected behavior

code should compile

Environment

irrelevant but Swift 6, M-series mac.

Additional information

No response

@MahdiBM MahdiBM added kind/bug Feature doesn't work as expected. status/triage Collecting information required to triage the issue. labels Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Feature doesn't work as expected. status/triage Collecting information required to triage the issue.
Projects
None yet
Development

No branches or pull requests

1 participant