[BUG] [python] additional_properties_type not set correctly in models
Created by: spacether
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
Using a v3 spec for an object schema, when additionalProperties is True or unset or {} the type should be set for it
Looking at our generated models, the type is not set at the model level though it IS being set in CodegenProperty
The expected output is to have additional_properties_type = {str, int, float...}
when it is incorrectly being set to additional_properties_type = None
This issue: https://github.com/OpenAPITools/openapi-generator/issues/8813 Is also a blocker on getting this working because I need to define the vars that only the composed schema includes at the composed schema level.
openapi-generator version
5.0.0
OpenAPI declaration file content or url
# openapi-generator generate -i issue_8743v3_wrong_response_type.yaml -o issue_8743v3 -g python
openapi: 3.0.1
info:
title: Quick Base API
version: 1.0.0
servers:
- url: //api.quickbase.com/
paths:
/fields/{fieldId}:
get:
description: Gets the properties of an individual field, based on field id.
parameters:
- name: fieldId
in: path
required: true
schema:
type: integer
responses:
200:
description: Success
content:
'*/*':
schema:
type: object
properties:
id:
type: integer
fieldType:
type: string
label:
type: string
properties:
$ref: '#/components/schemas/FieldProperties'
components:
schemas:
FieldProperties:
type: object
properties:
comments:
type: string
format:
type: string
maxLength:
type: integer
allowNewChoices:
type: boolean
displayAsLink:
type: boolean
allowHTML:
type: boolean
description: 'Additional properties for the field. '
Generation Details
openapi-generator generate -i issue_8743v3_wrong_response_type.yaml -o issue_8743v3 -g python
Steps to reproduce
Generate the client and look in both generated models. Both models lack the expected additionalProperties description.
Related issues/PRs
This came up when investigating https://github.com/OpenAPITools/openapi-generator/issues/8743
Suggest a fix
- Update the model template to set additional_properties_type
- If the value does not exist, then set it in the java layer
- make sure that the users will be able to set disallowAdditionalPropertiesIfNotPresent = True
- right now the generator is hard coding this to False. We should default to false, and allow true to be passed in.