Bug Report Checklist
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 febf496 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.
Bug Report Checklist
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
JSONEncodableprotocol, which isn't defined in the output.openapi-generator version
The problem was introduced in release v5.4.0 with commit febf496 and exists in 6.0.0 and in the current master branch.
OpenAPI declaration file content or url
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=falseSteps to reproduce
mymodel.yamlRelated 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.