[BUG][Swift] Generating standalone Swift models should not conform them to JSONEncodable
Created by: stjernegard
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
Have you tested with the latest master to confirm the issue still exists? -
Have you searched for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Swift models when generated without API or supporting files, should not conform to protocols defined only in those supporting files.
Currently the swift5 generator outputs models conforming to a JSONEncodable
protocol, which isn't defined in the output.
openapi-generator version
The problem was introduced in release v5.4.0 with commit https://github.com/OpenAPITools/openapi-generator/commit/febf49662a4d4fda5dbeed4888a1840db801177d and exists in 6.0.0 and in the current master branch.
OpenAPI declaration file content or url
---
openapi: '3.0.0'
paths:
/:
get:
responses:
200:
description: OK
description: Dummy endpoint
info:
title: MyModel
version: '1.0.0'
components:
schemas:
mymodel:
type: object
properties:
name:
type: string
Generation Details
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:v5.4.0 generate \
-i /local/mymodel.yaml \
-g swift5 \
-o /local/out \
--global-property=models,modelDocs=false
Steps to reproduce
- Save the above YAML file as
mymodel.yaml
- Run the above docker command
Related issues/PRs
There doesn't seem to be any other reports of the same bug. I tried searching all open and closed issues for JSONEncodable
, but found nothing relevant.
Suggest a fix
The protocol conformance could be only added if the protocol itself is also being generated.