Comments (15)
I just hit by this. still happened on 4.0.0.beta.
from openapi-generator.
I've started having a look at restoring InlineModelResolver.java - see https://github.com/bjgill/openapi-generator/tree/InlineModelResolver.
I'm now out of time to work on this for now, however. Anyone else who wants to pick this up would be more than welcome.
from openapi-generator.
OK - the following (v2) definition was fixed by #736 (thanks @antihax!):
ObjectOfObjects:
description: An object of objects
type: object
properties:
foo:
type: object
properties:
bar:
type: string
However, the following still doesn't seem to work (at least for rust-server
):
ArrayOfObjects:
description: An array of objects
type: array
items:
properties:
filename:
description: A non-required property
type: string
contents:
description: A required property
type: string
required:
- contents
type: object
from openapi-generator.
I think that all generators are concerned by the issue. This should be improved at DefaultCodegen level.
The inline form is broken as well (tested with a java generator)
openapi: 3.0.0
info:
title: Test
version: 1.0.0
servers:
- url: 'http://test/'
paths:
/test/ref/inline:
post:
summary: Test
requestBody:
content:
application/json:
schema:
type: object
properties:
test:
type: string
responses:
'200':
description: Success
content:
application/json:
schema:
type: string
—
I have investigated a little bit, comparing these 2 cases (can be added to DefaultCodegenTest
)
- Petstore case:
@Test
public void testPetInRequestBody() {
final OpenAPI openAPI = new OpenAPIParser().readLocation("src/test/resources/3_0/petstore.yaml", null, new ParseOptions()).getOpenAPI();
final DefaultCodegen codegen = new DefaultCodegen();
Operation operation = openAPI.getPaths().get("/pet").getPost();
CodegenOperation co = codegen.fromOperation("/pet", "post", operation, openAPI.getComponents().getSchemas(), openAPI);
Assert.assertEquals(co.bodyParam.dataType, “XXX”);
}
- Case described in this issue
ref_request_body.yaml
is the content posted by @Articus:
@Test
public void testRefRequestBody() {
final OpenAPI openAPI = new OpenAPIParser().readLocation("src/test/resources/3_0/ref_request_body.yaml", null, new ParseOptions()).getOpenAPI();
final DefaultCodegen codegen = new DefaultCodegen();
Operation operation = openAPI.getPaths().get("/test/ref/inline").getPost();
CodegenOperation co = codegen.fromOperation("/test/ref/inline", "post", operation, openAPI.getComponents().getSchemas(), openAPI);
Assert.assertEquals(co.bodyParam.dataType, “XXX”);
}
In the second case in the case where the name
is null (which is the name of the referenced schema), then codegenModel
is also null, and we goes in this branch with the warning "The folowing schema has undefined (null) baseType"... => https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java#L4321
Our test suite is working because of the $ref
at Schema level.
The current workaround is to write your spec like this:
openapi: 3.0.0
info:
title: Test
version: 1.0.0
servers:
- url: 'http://test/'
components:
schemas:
SomeObject:
type: object
properties:
test:
type: string
paths:
/test/ref/inline:
post:
summary: Test
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/SomeObject'
responses:
'200':
description: Success
content:
application/json:
schema:
type: string
from openapi-generator.
Consider case reported by @macjohnny in #222 when solving this issue.
from openapi-generator.
Consider case reported in #304, i.e. with OAS 2.0
from openapi-generator.
I've just independently re-discovered this in #659 (#99 and #231 look like more of the same).
This is a rather unfortunate regression from swagger-codegen. It is easy enough to work around, but a bit of a pain when trying to persuade other people to switch to openapi-generator.
From looking through the code, it seems as if the loss of InlineModelResolver
as part of 5359776 (the initial commit adding openapi v3 support) may be responsible.
from openapi-generator.
@bjgill thank you for the analysis, do you think you can propose a PR for this?
from openapi-generator.
I've also started digging through this and trying to resolve the changed function names. Are you actively working on this also? @bjgill
from openapi-generator.
No - I started work in https://github.com/bjgill/openapi-generator/tree/InlineModelResolver, but am not going to have time to work on this for the foreseeable future. I'd be very happy to let you handle this.
from openapi-generator.
I think support for items in array is exactly targeted by this test:
(and the next ones)
from openapi-generator.
I'm pretty sure the Go generator has the same problem (#1112). Is there something I can do to to help that generator? It sounds like a DefaultCodegen fix?
I've got an OpenAPI v3 spec, not v2 like mentioned in #8 (comment)
from openapi-generator.
I figured out my problem. It was missing components.schemas
for a components.requestBodies
.
https://github.com/moov-io/api/pull/43 was the fix for my project
from openapi-generator.
I am trying to use open api generator 5 to generate a client based on the jira cloud specification. Unfortunately, the request body model for doTransition
(#/components/schemas/IssueUpdateDetails
) is always missing, even though it is specified as described by #8 (comment). Any ideas what I might be missing? Is there any special configuration required?
from openapi-generator.
I think this issue have been solved (based on specified schema).
from openapi-generator.
Related Issues (20)
- [BUG] [Java] Invalid code generation for oneof types. HOT 1
- [BUG] Description
- Attempt to create a cumulative fix for missing Object.h, AnyType.h, Set.h for many generators: can you give me some knowledge you have to help me correcting them? HOT 2
- [BUG][RUST] Parameter with empty schema produces invalid rust code HOT 1
- [BUG][RUST] oneOf with multiple arrays produces invalid rust code HOT 2
- [BUG] [JAVA] Array of oneOf should be possible to be empty
- [BUG] [Java] oneOf inception provides wrong output in toJson HOT 4
- [BUG] [PYTHON] Model property: required AND default NOT combinable HOT 2
- [BUG][CSharp] DateOnly deserialized as DateTime and fails HOT 1
- [BUG] [JAVA] Cannot use oneOf as query parameter
- [BUG][JAVA] oneOf/anyOf validateJsonElement cannot find symbol
- [BUG][JAVA] oneOf/anyOf multiple constructors with same erasure
- [REQ] Add support for SecuritySchema mutualTLS
- [BUG][RUST-AXUM] rust-axum generator does not handle uuid::Uuid in headerParams
- [BUG][KOTLIN] kotlin-spring generator flag appendRequestToHandler generates broken code when used with flag delegatePattern
- [BUG][JAVA] {path} is URL Encoded
- [REQ] [ASPNETCORE] Add value types
- Documentation for typescript-fetch incorrectly indicates support for API and Model documentation
- [BUG] Generated Go (golang for the search algorithm) code does not compile.
- [kotlin-client] Upgrade versions of dependencies and Gradle
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openapi-generator.