Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@ public Context<?> toContext() {
final List<AuthorizationValue> authorizationValues = AuthParser.parse(this.auth);
ParseOptions options = new ParseOptions();
options.setResolve(true);
options.setResolveResponses(true);
SwaggerParseResult result = new OpenAPIParser().readLocation(inputSpec, authorizationValues, options);

// TODO: Move custom validations to a separate type as part of a "Workflow"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.openapitools.codegen.config;

import io.swagger.v3.oas.models.OpenAPI;
import org.junit.jupiter.api.Assertions;
import org.openapitools.codegen.ClientOptInput;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenConstants;
Expand Down Expand Up @@ -121,4 +123,14 @@ public void shouldSetConfigProperties() throws IOException {
want(props, "foo", "bar");
want(props, "baz", "quux");
}

@Test
public void resolvesResponses() {
@SuppressWarnings("unchecked") Context<OpenAPI> context = (Context<OpenAPI>) new CodegenConfigurator()
.setInputSpec("src/test/resources/3_0/response-ref.yaml")
.setGeneratorName("java")
.toContext();

Assertions.assertNotNull(context.getSpecDocument().getPaths().get("/hello").getGet().getResponses().get("200").getContent());
}
}
25 changes: 25 additions & 0 deletions modules/openapi-generator/src/test/resources/3_0/response-ref.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
openapi: 3.0.1
info:
title: ping test
version: '1.0'
servers:
- url: 'http://localhost:8000/'
paths:
/hello:
get:
operationId: hello
responses:
'200':
$ref: "#/components/responses/refResponse"

components:
responses:
refResponse:
description: a response specification `$ref`erenced from an operation
content:
application/json:
schema:
type: object
properties:
responseProperty:
type: string
Loading