SwaggerHub doesnt have the export options for Spring Server stubs openapi 3.0.0
HI Team, Thanks for OpenApi 3.0.0. Its defenitely enhancing the quality of the documents and reusable. But I dont see an option to export to Spring in Server stubs on openapi 3.0.0. I see only jaxrs options, please see the screen shot attached. Am I missing something?Solved2.3KViews0likes2Comments[JAVA] [JAX-RS] Server InvalidDefinitionException: Cannot construct instance by using oneOf
Hi Smartbear Community, I have the following swagger.yaml that uses theoneOfkeyword and I used the latest Swagger codegen tools (3.0.22) to create a server stub for JAX-RS Jersey. openapi: 3.0.0 info: version: 0.0.1 title: Polymorphism example description: '' paths: /animal: post: summary: Create a new animal requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/Animal' responses: '201': description: Created components: schemas: Animal: properties: name: type: string props: oneOf: - $ref: '#/components/schemas/Fish' - $ref: '#/components/schemas/Dog' Fish: type: object properties: depth: type: integer Dog: type: object properties: country: type: string I am trying to post the following example object: { "name":"Foo", "props":{ "country":"Bar" } } But this results in the following exception: javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `io.swagger.model.OneOfAnimalProps` (no Creators, like default construct, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 30] (through reference chain: io.swagger.model.Animal["props"]) at org.glassfish.jersey.servlet.WebComponent.serviceImpl (WebComponent.java:432) at org.glassfish.jersey.servlet.WebComponent.service (WebComponent.java:370) at org.glassfish.jersey.servlet.ServletContainer.service (ServletContainer.java:389) at org.glassfish.jersey.servlet.ServletContainer.service (ServletContainer.java:342) at org.glassfish.jersey.servlet.ServletContainer.service (ServletContainer.java:229) at org.eclipse.jetty.servlet.ServletHolder.handle (ServletHolder.java:808) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter (ServletHandler.java:1669) at io.swagger.api.ApiOriginFilter.doFilter (ApiOriginFilter.java:15) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter (ServletHandler.java:1652) at org.eclipse.jetty.servlet.ServletHandler.doHandle (ServletHandler.java:585) at org.eclipse.jetty.server.handler.ScopedHandler.handle (ScopedHandler.java:143) at org.eclipse.jetty.security.SecurityHandler.handle (SecurityHandler.java:577) at org.eclipse.jetty.server.session.SessionHandler.doHandle (SessionHandler.java:223) at org.eclipse.jetty.server.handler.ContextHandler.doHandle (ContextHandler.java:1127) at org.eclipse.jetty.servlet.ServletHandler.doScope (ServletHandler.java:515) at org.eclipse.jetty.server.session.SessionHandler.doScope (SessionHandler.java:185) at org.eclipse.jetty.server.handler.ContextHandler.doScope (ContextHandler.java:1061) at org.eclipse.jetty.server.handler.ScopedHandler.handle (ScopedHandler.java:141) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle (ContextHandlerCollection.java:215) at org.eclipse.jetty.server.handler.HandlerCollection.handle (HandlerCollection.java:110) at org.eclipse.jetty.server.handler.HandlerWrapper.handle (HandlerWrapper.java:97) at org.eclipse.jetty.server.Server.handle (Server.java:497) at org.eclipse.jetty.server.HttpChannel.handle (HttpChannel.java:310) at org.eclipse.jetty.server.HttpConnection.onFillable (HttpConnection.java:257) at org.eclipse.jetty.io.AbstractConnection$2.run (AbstractConnection.java:540) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob (QueuedThreadPool.java:635) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run (QueuedThreadPool.java:555) at java.lang.Thread.run (Thread.java:748) Swagger-codegen version Swagger-codegen version: 3.0.22 Command line used for generation CLI command:java -jar swagger-codegen-cli.jar generate -i openapi.yaml -l jaxrs-jersey -o jaxrs-jersey/ Any advise how to fix this issue is much appreciated!1.6KViews0likes4CommentsCodegen issues
My developers have raised a couple of issues with the code generated from Swaggerhub for the server (aspnet5 or aspnetcore). Firstly I've moved an enumerated attribute which is used in several definitions to a domain in order to separate this into it's own class which can be altered in isolation from the APIs. The models look good in the UI, attribute and enumerated values are there, but in the generated code this creates an empty class for the attribute. Additionally, when this attribute (or others) are defined in the actual API definition, codegen creates the attribute as a string value but does not add the enumerated literals. When we generate the client code (csharp) it works fine and picks up the enums. Is this working as expected? (and if so why)1.3KViews0likes0CommentsCodegen API Ordering for HTML Clients
For HTML clients theAPIs grouped by tags, are ordered alphabetically by tag. I have defined global tagsin mypreferred order. The Swagger UI seems to display as per my requirement, butCodegen for HTML Clientdoes not. Is there any setting to override this behaviour?Solved1.3KViews0likes2CommentsYaml working on editor but converted json has warnings on codegen build and fails to run
Good afternoon, I have written the yaml file for my project in the editor and converted it to json to have it generated using the swagger codegen tool.The steps I took worked for a previous iteration to this project but after adding ~1000 lines to the file something seems to have gone wrong. Below are the steps I took and the output I recieved. Generating the code started with this command java -jar swagger-codegen-cli-3.0.23.jar generate -i /home/swagger_projects/openapi.json -l python-flask -o FlaskConnexion-python2 -D supportPython2=true which spits out a bunch of this warning 15:59:37.278 [Thread-0] WARN i.s.c.v.g.DefaultCodegenConfig - String to be sanitized is null. Default to Object It finishes generating and then when I install the requirements and go to run the server I end up with the following error main__.py", line 5, in <module> from swagger_server import encoder File "swagger_server/encoder.py", line 4, in <module> from swagger_server.models.base_model_ import Model File "swagger_server/models/__init__.py", line 10, in <module> from swagger_server.models.body import Body File "swagger_server/models/body.py", line 9, in <module> from swagger_server.models.data import Data # noqa: F401,E501 File "swagger_server/models/data.py", line 9, in <module> from swagger_server.models.object import Object # noqa: F401,E501 ImportError: No module named object I assume that this error has something to do with the null strings defaulting to Objects, but I cannot find any more info on what that warning means. If anyone has any Idea on either how to fix the warnings or the error it would be greatly appreciated! I unfortunately cannot share the json as it is for my work project, but if anyone recognizes what type of behavior or patterns would cause these issues it would be extremely useful as well. Thank you!Generating Python client with valid docstrings
I'm using the currently latest swagger-codegen-cli-3.0.26.jarto generate Python client for my API. Then, I'm using Sphinxa to generate the client API reference in HTML format. The toolset invocation is pretty standard: sphinx-apidoc -f -o docs-python\_modules -e -P python\myclient docs-python\make.bat clean docs-python\make.bat html with a bunch of extensions in my `conf.py` for Sphinx: extensions = [ 'sphinx.ext.napoleon', 'sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx.ext.coverage' ] The `make.bat html` command outputs lots of warnings like these: WARNING: Block quote ends without a blank line; unexpected unindent. WARNING: Unexpected indentation. I noticed the generator outputs docstrings which are not entirely valid. It also includes lots of the directives like `# noqa: E501` which are dedicated for the Python linters. Is there any way to control the docstring flavour or format that `swagger-codegen` outputs? If the above looks like a bug, is https://github.com/swagger-api/swagger-codegen the right place to report it?Python Client for Shopware 6
Good Day, i have generated a python client via theswagger-codegen-cli docker image in my GitLab ci pipline for a Shopware 6 shop. The problem i encounter is that every endpoint returns empty data, but the strange part is that when i debug the client i can see the data via the inspector but then in one step befor the data is returned it tries todeserializethe data and it returns a dictonary without any data inside. return_data=response_data if_preload_content: #deserializeresponsedata ifresponse_type: return_data=self.deserialize(response_data,response_type) This is from the __call_api() function. When i inspect response_data i can see it contains the data i need but deserialize() return this: {'data': None, 'included': None, 'links': None, 'meta': None} i know i could set the parameter _preload_content to false but then i get the raw request response as a byte string and that kind of defeats the purpose of using a swagger client. Who should i contact or ask about this? Is it a problem of the specs from my shop? Is the codegen not working correctly? Or is the python generator from swagger the problem? What should i provide here so someone can help or point me in the right direction?