question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG][Python] deepObject parameter style creates invalid code on 5.0.1 and raises exception on 5.1.1

See original GitHub issue

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?
Description

when having a spec with deep objects parameter style, the python codegen creates invalid code on generator 5.0.x and fails altogether on generator 5.1.x

on 5.0.x the bad code generated looks like api_50/api/hosts_api.py:from api_50.model.str_bool_date_datetime_dict_float_int_list_str_none_type import StrBoolDateDatetimeDictFloatIntListStrNoneType

on 5.1.x even considering them triggers

[main] ERROR o.o.codegen.DefaultCodegen - Undefined property/schema for `filter`. Default to type:string.
[main] ERROR o.o.codegen.DefaultCodegen - Undefined property/schema for `filter`. Default to type:string.
Exception in thread "main" java.lang.RuntimeException: Could not process operation:
openapi-generator version
  • 5.1.1
  • 5.0.1
OpenAPI declaration file content or url

api spec

relevant item is a used


components:
  parameters:
    filter_param:
      in: query
      name: filter
      required: false
      style: deepObject
      explode: true
      schema:
       type: object
Generation Details/ steps to reproduce
Related issues/PRs

i haven’t found anything quite related

Suggest a fix

my current workaround is to use 5.1.x templates , the 5.0.x codegen and to post-process the generated files dropping the bad lines it would be nice if there was a configuration option to set a deep_object_hook so users can provide a own serialization/de-serialization for deep_objects

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
kevinkirkupcommented, Jan 25, 2022

I don’t mind updating the template, but I don’t have an environment to fix the exception being thrown:

1  Exception: null
2        at org.openapitools.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:1159)
3        at org.openapitools.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:1050)
4        at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:549)
5        at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:891)
6        at org.openapitools.codegen.cmd.Generate.execute(Generate.java:441)
7        at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
8        at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
9  Caused by: java.lang.NullPointerException
10        at org.openapitools.codegen.languages.PythonClientCodegen.fromProperty(PythonClientCodegen.java:440)
11        at org.openapitools.codegen.DefaultCodegen.fromParameter(DefaultCodegen.java:4752)
12        at org.openapitools.codegen.DefaultCodegen.fromOperation(DefaultCodegen.java:4113)
13        at org.openapitools.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:1127)

https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java#L440

0reactions
spacethercommented, Mar 30, 2022

@kevinkirkup my PR will fix the NPE issue but does not add the deep object serialization

Read more comments on GitHub >

github_iconTop Results From Across the Web

swagger-ui docker image: Help understanding why query ...
I'm trying to define OpenAPI for a query parameter that uses a simple type for a deepObject. According ...
Read more >
Common Errors - AWS SimSpace Weaver
InternalFailure. The request processing has failed because of an unknown error, exception or failure. HTTP Status Code: 500. InvalidAction.
Read more >
OpenApiSpex.Parameter — open_api_spex v3.16.0 - HexDocs
Parameter Object. Describes a single operation parameter. A unique parameter is defined by a combination of a name and location.
Read more >
Model Binding in ASP.NET Core | Microsoft Learn
When the page is redisplayed by the preceding code, the invalid input isn't shown in the form field. This is because the model...
Read more >
SQL Exception and Warning Messages - SAP Help Portal
See Installing Stored Procedures in the SAP jConnect for JDBC Installation Guide . 010P4. An output parameter was received and ignored. Description: The...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found