swagger-codegen

How do I update RestTemplate to correctly map Java Dates?

橙三吉。 提交于 2019-12-02 04:12:07
I have an issue where my RestTemplate.postForEntity(url, restRequest, RepoResponse.class) call is failing because it can't deserialise dates of the form: 2019-02-01T12:00:00.000-0500 because of the missing colon in the timezone. Based on this answer , it looks like I want to change the date formatting of my RestTemplate 's ObjectMapper . I've tried a solution here: https://stackoverflow.com/a/38286322/14250 Which gives me the following code: restTemplate = new RestTemplate(); ObjectMapper objectMapper = new ObjectMapper(); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss

Generated Swagger REST client does not handle + character correctly for query parameter

流过昼夜 提交于 2019-12-02 02:12:17
I have this Spring REST controller method: @ApiOperation("My method") @RequestMapping(method = RequestMethod.POST, value = "/myMethod") public void myMethod(@RequestParam("myParam") String myParam) { ... } The REST client is generated using swagger codegen CLI with language Java and library resttemplate : public void myMethod(String myParam) throws RestClientException { ... return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } And the source code for ApiClient#invokeAPI - which is also generated - is:

Swagger Codegen (with maven plugin) for OpenAPI 3.0

你说的曾经没有我的故事 提交于 2019-12-01 16:06:11
I want to use Swagger Codegen for OpenAPI 3.0 YAML file. And I see Swagger Codegen 3.0.0-rc0 is available. But when I try to use that I run into issues. Following are the details: My pom.xml file with swagger-codegen plugin: <plugin> <groupId>io.swagger</groupId> <artifactId>swagger-codegen-maven-plugin</artifactId> <version>3.0.0-rc0</version> <executions> <execution> <goals> <goal>generate</goal> </goals> <configuration> <inputSpec>${basedir}/src/main/resources/mySpec.yaml</inputSpec> <output>target/generated-sources</output> <language>spring</language> <generateApis>false</generateApis>

How to properly use the server stubs generated from a swagger specification?

别说谁变了你拦得住时间么 提交于 2019-12-01 04:46:01
I'm using Swagger 2.0 and swagger-codegen (actually the swagger-codegen-plugin for Maven) to specify,document and generate an API, with Java as the target language. The project is already setup to build the server stubs (JAX-RS) and documentation, and Eclipse recognizes the generated code in the project buildPath. I'm not sure of what is the proper workflow from here. :-/ I don't think I should modify the generated classes, otherwise my changes would be overwritten whenever I change the swagger spec, an I expect it will change as I think more about the API as the development goes on. What

How to run swagger-codegen for OpenAPI 3.0.0

巧了我就是萌 提交于 2019-12-01 03:37:22
looks like official swagger for openapi specification V3 support is near release https://blog.readme.io/an-example-filled-guide-to-swagger-3-2/ , and the swagger-codegen has 3.0.0 support developed and passing some level of testing https://github.com/swagger-api/swagger-codegen on the 3.0.0 branch I have a swagger spec (generated from my existing 2.0 spec via https://github.com/mermade/swagger2openapi , output looks good) Is there an easy way to run the swagger-codegen without having to package the jar myself? this is the single result i found: https://oss.sonatype.org/content/repositories

How to properly use the server stubs generated from a swagger specification?

久未见 提交于 2019-12-01 01:25:35
问题 I'm using Swagger 2.0 and swagger-codegen (actually the swagger-codegen-plugin for Maven) to specify,document and generate an API, with Java as the target language. The project is already setup to build the server stubs (JAX-RS) and documentation, and Eclipse recognizes the generated code in the project buildPath. I'm not sure of what is the proper workflow from here. :-/ I don't think I should modify the generated classes, otherwise my changes would be overwritten whenever I change the

How to generate constructors in swagger codegen?

巧了我就是萌 提交于 2019-11-30 19:14:26
The codegen did not generate any constructor. I referred to petstore swagger file, used latest swagger codegen jar file. But only default constructor was generated. It is not generating constructor based on its fields. How to enable it? If you really need a constructor with parameters you can do so by modifying the template file(s) that end with .moustache. "enable/use/modify" templates I'm going to assume you're going to be editing an existing template and want a constructor for each model. Here is a simple example of a constructor inside the model template file: public {{classname}}( {{#vars

Can you completely disable CORS support in Spring?

泄露秘密 提交于 2019-11-30 11:27:41
As described in CORS preflight request fails due to a standard header if you send requests to OPTIONS endpoints with the Origin and Access-Control-Request-Method headers set then they get intercepted by the Spring framework, and your method does not get executed. The accepted solution is the use @CrossOrigin annotations to stop Spring returning a 403 . However, I am generating my API code with Swagger Codegen and so I just want to disable this and implement my OPTIONS responses manually. So can you disable the CORS interception in Spring? From their documentation : If you are using Spring Web

Kubernetes 支持 OpenAPI

旧街凉风 提交于 2019-11-30 08:22:16
Open API 让 API 提供者可以定义自己的操作和模型,并让开发者可以自动化的生成喜欢语言的客户端,用以和 API 服务器通信。Kubernetes 已经支持 Swagger 1.2(OpenAPI 规范的前身)有一段时间了,但是这一标准不够完整和有效,凭借这一支持,非常难生成工具或客户端。 在 Kubernetes 1.4 ,我们对目前的模型和操作进行了升级,引入了 Open API 规范(在没被捐献给 Open API 之前被称作 Swagger 2.0)支持的 Alpha 版本。从 Kubernetes 1.5 开始,OpenAPI 规范的支持已经完备,能够直接从 Kubernetes 源码生成规范,对于模型和方法的任何变更,都会保障文档和规范的完全同步。 新规范让我们有了更好的 API 文档,甚至还有了一个 Python 客户端。 这一模块化的规范用 GroupVersion 进行分隔,这一做法属于未雨绸缪,我们想要让不同的 API Server 使用不同的 GroupVersion。 规范的结构在 Open API spec definition 中有解释。我们用 operation 标记 来拆分每个 GroupVersion 并尽可能的丰富其中的模型、路径、操作等信息。操作的参数、调用方法以及响应都有文档描述。 例如,获取 Pod 信息的 OpenAPI 规范 {

swagger-codegen生成java客户端代码

﹥>﹥吖頭↗ 提交于 2019-11-30 08:22:01
前后端分离的时候,需要建立契约,Swagger可达到该目的(略)。 建立Rest接口后,通过swagger-codegen项目可以自动生成对应的客户端代码(c++、php、java、js、node等等), 关于swagger-codegen项目的使用,发现中文文档较少,追根述源后,发现其中相当一部分同出一辙。 亲自摸索使用后,记录一下步骤,利己利人。 swagger-codegen项目地址: https://github.com/swagger-api/swagger-codegen 项目文档(README.md)说的比较详细,但是重复的地方太多,容易让新手搞晕。 其实,文档内容可以简化为如下步骤(凡‘略’,皆不予理睬): 【注意】以下步骤,均在Windows系统中操作,生成java客户端代码,其他语言类似;英文不好,有些不会翻译,故保留英文原文; 1、Table of contents(略) 2、Compatibility(略) 3、Prerequisites 3.1、从maven仓库下载swagger-codegen的jar文件,如下 <!-- https://mvnrepository.com/artifact/io.swagger/swagger-codegen --> <dependency> <groupId>io.swagger</groupId>