OpenAPITools / OpenAPITools/openapi-generator
How to get the request path in code.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
While implementing a POST body.
I want to return status of 201 Created along with the URI. However, how do i get the request-path in the first place..
@Override
public ResponseEntity<Void> createPet (Pet p ) {
Pet p1 = petRepository.save(p);
return ResponseEntity.created(" request-path.. ?? " + p1.id); // <-- how can i get the input path here
}
i dont want to hard-code request-path.
- Below is my (pretty regular) pom file.
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>7.5.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpecRootDirectory> ${project.basedir}/src/main/resources/openapi
</inputSpecRootDirectory>
<generatorName>spring</generatorName>
<apiPackage>com.example.openapi.api</apiPackage>
<modelPackage>com.example.openapi.model</modelPackage>
<configOptions>
<modelSuffix>Dto</modelSuffix>
<useJakartaEe>true</useJakartaEe>
<library>spring-boot</library>
<delegatePattern>true</delegatePattern>
<hideGenerationTimestamp>true</hideGenerationTimestamp>
<interfaceOnly>true</interfaceOnly>
<useSpringBoot3>true</useSpringBoot3>
<useSpringfox>false</useSpringfox>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
```
</details>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no repository files or tests; start by inspecting the generated Spring API interface and delegate for createPet, along with the request mapping produced from the OpenAPI definition. Compare the available request context with the ResponseEntity.created call, and consider the issue complete only when the expected approach is documented or the generator behavior is changed and verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, spring, spring-boot
- Domain
- api, backend, tooling
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100