swagger-2.0

Best way to denote time (without date) in Swagger spec

匆匆过客 提交于 2019-12-19 10:17:17
问题 What is the best way to represent a time field in a swagger specification, the closest type to denote it looks like date-time but this makes standard deserialisers to expect date field to be passed along with the time... Is there a standard or best practice to just denote time in a swagger spec that works well with the Jackson deserialisers? Is denoting time in milliseconds/seconds and using type string in swagger an acceptable approach? 回答1: Depending on what you're trying to represent, this

Convert JSON to JSON Schema draft 4 compatible with Swagger 2.0

爷,独闯天下 提交于 2019-12-18 19:10:32
问题 I've been given some JSON files generated by a REST API with plenty of properties. I've created a Swagger 2.0 definition for this API and need to give it the corresponding schema for the response. The main problem: this JSON file has loads of properties. It would take so much time and I would make many mistakes if I write the schema manually. And it’s not the only API I need to describe. I know there are some tools to convert JSON to JSON schemas but, if I’m not mistaken, Swagger only has

Why error in Angular 5 as : has no exported member 'OpaqueToken'.?

微笑、不失礼 提交于 2019-12-18 07:03:19
问题 I have an Angular 4 application, which I am upgrading to Angular 5. I am getting the following error. ERROR in src/app/application/services/generated/variables.ts(1,10): error TS2305: Module '"..../node_modules/@angular/core/core"' has no exported member 'OpaqueToken'. Code snippet is : import { OpaqueToken } from '@angular/core'; export const BASE_PATH = new OpaqueToken('basePath'); export const COLLECTION_FORMATS = { 'csv': ',', 'tsv': ' ', 'ssv': ' ', 'pipes': '|' } This code is been

How to change Swagger-ui URL prefix?

有些话、适合烂在心里 提交于 2019-12-18 03:44:41
问题 I am using Springfox Swagger2 with Spring boot 1.5.9. I can access swagger UI on this link. http://localhost:8090/swagger-ui.html How can I change it to be available on following URL? http://localhost:8090/my/custom/path/swagger-ui.html @EnableSwagger2 public class Configuration { @Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.basePackage("my.favorite.package")) .paths(PathSelectors.any()) .build() .apiInfo(apiInfo())

Array of objects as an input parameter in swagger

柔情痞子 提交于 2019-12-18 02:58:24
问题 I'm trying to describe the following post parameter in swagger: { "sources": [ { "id": 101, "parentId": 201 },{ "id": 102, "parentId": 201 },{ "id": 102, "parentId": 202 } ], "destinationId": 301, "param1": "value 1", "param2": "value 2", } The issue is that the sources is an array of objects, that swagger does not seem to support. Here is what I tried: paths: /bulk-action: post: parameters: - name: sources in: formData type: array enum: $ref: '#/definitions/BulkSource' - name: destinationId

Using @RequestParam annotated method with swagger ui

蹲街弑〆低调 提交于 2019-12-18 01:52:53
问题 I am using Springfox libraries to generate documentation for REST service and display it in Swagger UI. I followed the directions in Springfox documentation. I have one controller, which uses parameters from query string and the method is mapped as following: @ApiOperation(value = "") @RequestMapping(method = GET, value = "/customcollection/{id}/data") public Iterable<CustomeType> getData(@ApiParam(value = "The identifier of the time series.") @PathVariable String id, @ApiParam(name =

Swagger: variant schema shape dependant on field value

前提是你 提交于 2019-12-17 21:19:27
问题 I have a model defined as: Event: type: object properties: id: type: string timestamp: type: string format: date-time type: type: string enum: - click - open - sent click: type: object properties: url: type: string title: type: string open: type: object properties: subject: type: string sent: type: object properties: subject: type: string from: type: string to: type: string However, the shape is actually different depending on the value of the type enum field. It can be one of three, I tried

Swagger 2.0: Multiple Path objects with different paths but same request and response

让人想犯罪 __ 提交于 2019-12-17 20:49:00
问题 Due to some backward compatibility reasons, I need to support both the paths /ab and /a-b . The request and response objects are going to be the same for both of the paths. Can I have something like the following in my Swagger spec so that I do not have to repeat the request and response object definitions for both the paths. paths: /ab: /a-b: post: ... 回答1: Yes, you can have a path item reference another path item, like this: paths: /ab: ... /a-b: $ref: '#/paths/~1ab' Here, ~1ab is an

Why does springfox-swagger2 UI tell me “Unable to infer base url.”

只谈情不闲聊 提交于 2019-12-17 20:02:44
问题 Why does springfox-swagger2 UI tell me Unable to infer base url. As far as I know, I am using a typical Swagger spring-boot configuration. As you can see in the screenshot, the swagger-fox url backing the UI is example.com/api . NOTE: I get a standard Spring Whitelabel Error Page when I navigate to: https://localhost:9600/api/v2/api-docs/ . I suspect this is the root of the problem? I see no errors that Spring didn't load springfox-swagger2 and so I don't know why that isn't working. My

“discriminator” in polymorphism, OpenAPI 2.0 (Swagger 2.0)

杀马特。学长 韩版系。学妹 提交于 2019-12-17 19:57:17
问题 Referencing OpenAPI 2.0, Schema Object, or Swagger 2.0, Schema Object, and the definition of discriminator field as: Adds support for polymorphism. The discriminator is the schema property name that is used to differentiate between other schema that inherit this schema. The property name used MUST be defined at this schema and it MUST be in the required property list. When used, the value MUST be the name of this schema or any schema that inherits it. My confusions/ questions: It is ambiguous