-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HASKELL] haskell-http-client generator doesn't understand allOf
schemas
#7411
Comments
I will review - thanks |
This appears to be an issue with all generators (at least those using static types), as far as I can tell. I tried generating with
and they all fail for this case. related issues: #2924 moby/moby#27919 Since this appears to be an issue with the base/core swagger-codegen code, I'm not sure there's an immediate fix i can make to I recommend modifying the swagger.yaml directly to inline/remove the Some issues mention moving the Would like to hear from others on if this is an expected use case. @wing328 |
Ah okay, thanks for investigating @jonschoning! Slightly off-topic, but another workaround I tried was to use selective generation to exclude problematic parts, i.e. something like |
Selective generation does appear to be a bug with |
The other use-case for selective generation besides working around bugs is that some APIs are gigantic--when I compile the whole Docker API it results in a ~20MB Haskell library. Is it possible it will be added someday? I'm happy to open an issue for it if it helps. |
for To control the specific files being generated, I wasn't able to get the CSV list of |
You can add go-server generator to the list as well. swagger: '2.0'
info:
version: 0.0.1
description: so many issues
title: superb api
host: 'localhost:8080'
basePath: /
schemes:
- http
definitions:
stuff-group:
properties:
stuffs:
properties:
stuff:
items:
allOf:
- $ref: '#/definitions/stuff-group2'
- properties:
stuff-name:
type: string
description: Name of the stuff
x-key: stuff-name
type: array
stuff-group2:
properties:
foo:
type: string
description: superb value When fed into the generator, I get the following error:
The generated stub looks like this: package swagger
type xxx struct {
Stuff []ErrorUnknown `json:"stuff,omitempty"`
} |
I ran into this issue today, get a Had you fixed your problem, do you have any solution for it? |
Same error with latest version os master using the Java CLI and maven plugin. |
This seems to be resolved for Haskell at least, using 2.4.21. |
Description
I'm trying to generate
haskell-http-client
code to use with Docker's API. However, the codegen seems to be not understanding what to do when anallOf
is found in a schema. For example, Docker's v1.25 API contains this snippet:However, in the generated code for this API endpoint, the "body" type is simply missing:
Swagger-codegen version
Version 2.3.1
Swagger declaration file content or url
See above for snippet; URL is https://docs.docker.com/engine/api/v1.25/swagger.yaml
Command line used for generation
rm -rf /tmp/haskell_api_client; mkdir /tmp/haskell_api_client; java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i https://docs.docker.com/engine/api/v1.25/swagger.yaml -l haskell-http-client -o /tmp/haskell_api_client
Steps to reproduce
Clone the
swagger-codegen
repo and then run the command above inside it. You can see the problematic code in/tmp/haskell_api_client/lib/DockerEngine/API.hs
Related issues/PRs
Not that I can see.
Suggest a fix/enhancement
I'm guessing the codegen is simply missing handling for this case. It might be necessary to generate a whole new type for the "combined" body created by an
allOf
. It might also be possible to do something clever with a product type of the components of theallOf
and then handle packing/unpacking them in the AesonToJSON
/FromJSON
instances.The text was updated successfully, but these errors were encountered: