Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

openapi-generator cannot process Web API spec #19

Closed
4 of 9 tasks
imax9000 opened this issue Mar 31, 2019 · 8 comments
Closed
4 of 9 tasks

openapi-generator cannot process Web API spec #19

imax9000 opened this issue Mar 31, 2019 · 8 comments

Comments

@imax9000
Copy link

imax9000 commented Mar 31, 2019

Description

openapi-generator seems to be unable to process Web API spec. Same goes for swagger-codegen

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

Development environment:
Mac OS X 10.14.3 with Homebrew
openapi-generator 3.3.4

Steps to reproduce:

  1. brew install openapi-generator
  2. openapi-generator generate -i ../slack-api-spec/web-api/slack_web_openapi_v2.json -g go

Expected result:

Client code generated.

Actual result:

% openapi-generator generate -i ../slack-api-spec/web-api/slack_web_openapi_v2.json -g go --skip-validate-spec
[main] WARN  io.swagger.util.PropertyDeserializer - no property from null, null, {ENUM=null, TITLE=null, DESCRIPTION=null, DEFAULT=null, PATTERN=null, DESCRIMINATOR=null, MIN_ITEMS=null, MAX_ITEMS=null, MIN_PROPERTIES=null, MAX_PROPERTIES=null, MIN_LENGTH=null, MAX_LENGTH=null, MINIMUM=null, MAXIMUM=null, EXCLUSIVE_MINIMUM=null, EXCLUSIVE_MAXIMUM=null, UNIQUE_ITEMS=null, EXAMPLE=null, TYPE=null, FORMAT=null, READ_ONLY=null, VENDOR_EXTENSIONS={}, MULTIPLE_OF=null}
[main] WARN  io.swagger.util.PropertyDeserializer - no property from null, null, {ENUM=null, TITLE=null, DESCRIPTION=null, DEFAULT=null, PATTERN=null, DESCRIMINATOR=null, MIN_ITEMS=null, MAX_ITEMS=null, MIN_PROPERTIES=null, MAX_PROPERTIES=null, MIN_LENGTH=null, MAX_LENGTH=null, MINIMUM=null, MAXIMUM=null, EXCLUSIVE_MINIMUM=null, EXCLUSIVE_MAXIMUM=null, UNIQUE_ITEMS=null, EXAMPLE=null, TYPE=null, FORMAT=null, READ_ONLY=null, VENDOR_EXTENSIONS={}, MULTIPLE_OF=null}
[main] WARN  io.swagger.util.PropertyDeserializer - no property from null, null, {ENUM=null, TITLE=null, DESCRIPTION=null, DEFAULT=null, PATTERN=null, DESCRIMINATOR=null, MIN_ITEMS=null, MAX_ITEMS=null, MIN_PROPERTIES=null, MAX_PROPERTIES=null, MIN_LENGTH=null, MAX_LENGTH=null, MINIMUM=null, MAXIMUM=null, EXCLUSIVE_MINIMUM=null, EXCLUSIVE_MAXIMUM=null, UNIQUE_ITEMS=null, EXAMPLE=null, TYPE=null, FORMAT=null, READ_ONLY=null, VENDOR_EXTENSIONS={}, MULTIPLE_OF=null}
[main] WARN  io.swagger.util.PropertyDeserializer - no property from null, null, {ENUM=null, TITLE=null, DESCRIPTION=null, DEFAULT=null, PATTERN=null, DESCRIMINATOR=null, MIN_ITEMS=null, MAX_ITEMS=null, MIN_PROPERTIES=null, MAX_PROPERTIES=null, MIN_LENGTH=null, MAX_LENGTH=null, MINIMUM=null, MAXIMUM=null, EXCLUSIVE_MINIMUM=null, EXCLUSIVE_MAXIMUM=null, UNIQUE_ITEMS=null, EXAMPLE=null, TYPE=null, FORMAT=null, READ_ONLY=null, VENDOR_EXTENSIONS={}, MULTIPLE_OF=null}
[main] WARN  o.o.c.config.CodegenConfigurator - There were issues with the specification, but validation has been explicitly disabled.
Errors: 
	-attribute definitions.objs_file_object_with_id_only.title is unexpected
	-attribute definitions.objs_file_object_with_id_only.additionalProperties is unexpected
	-attribute definitions.objs_file_object_with_id_only.type is unexpected
Warnings: 
	-Unused model: defs_comment_id
	-Unused model: defs_ok_false
	-Unused model: objs_team
	-Unused model: defs_ts
	-Unused model: defs_invite_id
	-Unused model: defs_room_id
	-Unused model: objs_inviting_user
	-Unused model: defs_team
	-Unused model: defs_group_id
	-Unused model: defs_ok_true
	-Unused model: objs_file_object_with_id_only
	-Unused model: defs_dm_id
	-Unused model: defs_bot_id
	-Unused model: objs_reaction
	-Unused model: objs_comment
	-Unused model: defs_topic_purpose_creator
	-Unused model: objs_channel
	-Unused model: defs_pinned_info
	-Unused model: defs_app_id
	-Unused model: objs_group
	-Unused model: objs_file
	-Unused model: objs_im
	-Unused model: objs_paging
	-Unused model: objs_team_profile_field
	-Unused model: objs_conversation
	-Unused model: objs_user
	-Unused model: objs_dnd
	-Unused model: prefs_prefs
	-Unused model: objs_scopes
	-Unused model: defs_file_id
	-Unused model: objs_comments
	-Unused model: defs_channel
	-Unused model: defs_user_id
	-Unused model: objs_message
	-Unused model: objs_user_profile
	-Unused model: team_prefs_prefs
	-Unused model: objs_user_profile_short
	-Unused model: defs_channel_name
	-Unused model: defs_channel_id
	-Unused model: objs_user_profile_shortest

[main] INFO  o.o.c.ignore.CodegenIgnoreProcessor - No .openapi-generator-ignore file found.
[main] INFO  o.o.c.languages.AbstractGoCodegen - Environment variable GO_POST_PROCESS_FILE not defined so Go code may not be properly formatted. To define it, try `export GO_POST_PROCESS_FILE="/usr/local/bin/gofmt -w"` (Linux/Mac)
[main] INFO  o.o.c.languages.AbstractGoCodegen - NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] INFO  o.o.codegen.DefaultGenerator - Model objs_comments not generated since it's an alias to array (without property)
[main] INFO  o.o.codegen.DefaultGenerator - Model defs_pinned_info not generated since it's an alias to map (without property)
Exception in thread "main" java.lang.RuntimeException: Could not process model 'team_prefs_prefs'.Please make sure that your schema is correct!
	at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:457)
	at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:888)
	at org.openapitools.codegen.cmd.Generate.run(Generate.java:355)
	at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:62)
Caused by: java.lang.NullPointerException
	at org.openapitools.codegen.utils.ModelUtils.isArraySchema(ModelUtils.java:343)
	at org.openapitools.codegen.languages.AbstractGoCodegen.getTypeDeclaration(AbstractGoCodegen.java:263)
	at org.openapitools.codegen.languages.AbstractGoCodegen.getTypeDeclaration(AbstractGoCodegen.java:266)
	at org.openapitools.codegen.DefaultCodegen.fromProperty(DefaultCodegen.java:2006)
	at org.openapitools.codegen.DefaultCodegen.addVars(DefaultCodegen.java:3455)
	at org.openapitools.codegen.DefaultCodegen.addVars(DefaultCodegen.java:3425)
	at org.openapitools.codegen.DefaultCodegen.addVars(DefaultCodegen.java:3412)
	at org.openapitools.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:1708)
	at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1126)
	at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:452)
	... 3 more
@episod
Copy link
Contributor

episod commented Jun 10, 2019

👋 Looking into this, thanks! It may not get resolved to our next spec release, but that shouldn't be too far away now. File comments are now more or less retired from the platform, so as a short term fix you could remove the object reference and any method responses aspects that reference it.

@losttime
Copy link

losttime commented Jul 3, 2019

I'm running into this as well. Considering this repo doesn't get updates too frequently, is an impending update something like weeks away, or more like months?

@aSapien
Copy link

aSapien commented Jul 14, 2019

Wow, I'm glad I came across this issue. I had almost given up completely.
Is there an ETA on getting this fixed?

@episod
Copy link
Contributor

episod commented Jul 17, 2019

Hello! Sorry for the long wait. We've published a new version of the spec to master that should fix most of the issues you're running into with validators and code generators. I was able to generate the skeleton of a Go project using openapi-generator with the newest spec. Let us know how it works for you.

@aSapien
Copy link

aSapien commented Jul 20, 2019

@episod thanks! I can confirm that both openapi-generator and swagger-codegen successfully generate Scala models and stubs for the Web API.

Is there any chance I can generate Scala models for the Events API as well?

@episod
Copy link
Contributor

episod commented Jul 23, 2019

@aSapien great!

We do have a similar kind of spec for the Events API, though it's a little out of date and the deep schema coverage is sadly light. It's a format called AsyncAPI and there is some tooling around it for code generation, though it's still in the early days. We should begin working on a more up to date version of this spec later this year. See https://github.com/slackapi/slack-api-specs/tree/master/events-api

@episod episod closed this as completed Jul 23, 2019
@aSapien
Copy link

aSapien commented Jul 28, 2019

@episod Thanks. I'm familiar with the AsyncAPI, unfortunately I couldn't find any Scala code generator for AsyncAPI specs...

@tihomir-kit
Copy link

tihomir-kit commented Feb 2, 2021

I hope nobody will mind me putting this here, but since this seems to be top google result when looking into this issue, to save people a bit of time in case they're using .Net WebAPI, this will help you. 🖖🏻

I put [Produces(MediaTypeNames.Application.Json)] on my AppControllerBase (which inherits ControllerBase and is inherited by all my controllers) to avoid having to add it on every single controller action. I then keep adding [Consumes(MediaTypeNames.Application.Json)] and [Produces(typeof(SomeType))] where needed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants