如何导出Swagger定义文件(它应该是JSON或YAML文件)?我被要求这样做,而且我对Swagger只有粗略的了解.
我们确实有一个端点http://example.com//swagger/ui/index#!看起来像这样(截图不是我们真正的端点,但我不能发布):
版本是api version: v1.
我看不到"导出"按钮.那么我该如何导出呢?
我想重新格式化一些单个字符串的SQL语句,其中新行更容易阅读.
我个人并不知道缩进SQL的良好编码风格 - 如何通过表示嵌套查询/ where子句/ left join/etc来最大化可读性?
有没有人见过一个漂亮的打印算法呢?在Python中会更好.
我正在使用http://editor.swagger.io来设计API,我收到一个错误,我不知道如何解决:
Schema error at paths['/employees/{employeeId}/roles'].get.parameters[0]
should NOT have additional properties
additionalProperty: type, format, name, in, description
Jump to line 24
Run Code Online (Sandbox Code Playgroud)
我有其他端点以类似的方式定义,并没有得到此错误.我想知道我是否有一些缩进或未公开引号的问题,但似乎并非如此.谷歌似乎也没有提供任何有用的结果.
swagger: "2.0"
info:
description: Initial draft of the API specification
version: '1.0'
title: App 4.0 API
host: api.com
basePath: /v1
tags:
- name: employees
description: Employee management
schemes:
- https
paths:
/employees/{employeeId}/roles:
get:
tags:
- employees
summary: "Get a specific employee's roles"
description: ''
operationId: findEmployeeRoles
produces:
- application/json
parameters:
- name: employeeId <====== Line 24
in: …Run Code Online (Sandbox Code Playgroud) 我在VS2008中构建了一个Web安装项目,它将我的ASP.NET/Silverlight应用程序安装到IIS中.这在除Windows Server 2008之外的任何地方都可以正常工作
我在MSI安装程序日志文件中收到此错误消息:
MSI (c) (C8:D8) [15:02:21:067]: Invoking remote custom action. DLL: C:\Users\ADMINI~1\AppData\Local\Temp\1\MSIB7DD.tmp, Entrypoint: SetTARGETSITE
MSI (c) (C8!F0) [15:02:21:097]: Creating MSIHANDLE (14) of type 790531 for thread 2288
INFO : [08/27/2009 15:02:21:097] [SetTARGETSITE ]: Custom Action is starting...
INFO : [08/27/2009 15:02:21:107] [SetTARGETSITE ]: CoInitializeEx - COM initialization Apartment Threaded...
ERROR : [08/27/2009 15:02:21:107] [SetTARGETSITE ]: FAILED: -2147221164
ERROR : [08/27/2009 15:02:21:127] [SetTARGETSITE ]: Custom Action failed with code: '340'
INFO : [08/27/2009 15:02:21:137] [SetTARGETSITE ]: Custom Action completed …Run Code Online (Sandbox Code Playgroud) 几天前,应用程序正在使用 Springfox Swagger 3.0。突然它停止工作。一周前创建的 Jar 文件仍在工作,但现在当我们尝试构建一个新的 Jar 文件时,即使没有任何代码/库更改,它也无法工作。我什至参考了以下 URL,但仍然面临问题。
swagger-ui 和 spring webflux 的 404 错误
下面给出了我的配置:
POM文件:
<properties>
<java.version>1.8</java.version>
<springfox.version>3.0.0-SNAPSHOT</springfox.version>
<spring.version>2.3.1.RELEASE</spring.version>
</properties>
<repositories>
<repository>
<id>spring-libs-milestone</id>
<name>Spring Milestone Maven Repository</name>
<url>http://oss.jfrog.org/artifactory/oss-snapshot-local/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-spring-webflux</artifactId>
<version>${springfox.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox.version}</version>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
配置文件:
@Configuration
@EnableSwagger2WebFlux
public class SwaggerConfiguration implements WebFluxConfigurer {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(new ApiInfoBuilder()
.description("My Reactive API")
.title("My Domain object API") …Run Code Online (Sandbox Code Playgroud) 这里说我可以引用另一个文件中的定义来获取单个路径,但该示例似乎引用了整个文件,而不是对象下的单个路径定义paths。如何在另一个文件的paths对象中分配单独的路径?
例如,我有Anotherfile.yaml包含路径/a/b:
paths:
/a/b:
post:
Run Code Online (Sandbox Code Playgroud)
在另一个文件中,我使用如下方式$ref引用路径:/a/b
paths:
/c/d:
$ref: 'Anotherfile.yaml#/paths/a/b'
Run Code Online (Sandbox Code Playgroud)
但这给出了一个错误:
在 ./Anotherfile.yaml 的内容中找不到路径/a/b
我有一些引用NUnit的程序集,并使用单个测试方法创建一个测试类.我能够获得此程序集的文件系统路径(例如"C:...\test.dll").我想以编程方式使用NUnit来运行此程序集.
到目前为止,我有:
var runner = new SimpleTestRunner();
runner.Load(path);
var result = runner.Run(NullListener.NULL);
Run Code Online (Sandbox Code Playgroud)
但是,调用runner.Load(path)会抛出FileNotFound异常.我可以通过堆栈跟踪看到问题是NUnit在堆栈中调用Assembly.Load(path).如果我将路径更改为"Test,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null",那么我仍会得到相同的错误.
我已经向AppDomain.Current.AssemblyResolve添加了一个事件处理程序,以查看我是否可以手动解析此类型,但我的处理程序永远不会被调用.
让Assembly.Load(...)工作的秘诀是什么?
我正在尝试为一个时间间隔构建一个 Swagger 模型,使用一个简单的字符串来存储时间(我知道还有日期时间):
definitions:
Time:
type: string
description: Time in 24 hour format "hh:mm".
TimeInterval:
type: object
properties:
lowerBound:
$ref: "#/definitions/Time"
description: Lower bound on the time interval.
default: "00:00"
upperBound:
$ref: "#/definitions/Time"
description: Upper bound on the time interval.
default: "24:00"
Run Code Online (Sandbox Code Playgroud)
出于某种原因,生成的 HTML 没有显示lowerBound 和upperBound“描述”,而只显示原始时间“描述”。这让我觉得我没有正确地做这件事。
所以问题是,是否可以像我尝试的那样使用模型作为类型。
我正在尝试从swagger.jsonusing生成 java 代码,swagger-codegen-cli.jar但出现此异常:
Exception in thread "main" java.lang.RuntimeException: missing swagger input or config!
at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:763)
at io.swagger.codegen.cmd.Generate.run(Generate.java:299)
at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:35)
Run Code Online (Sandbox Code Playgroud)
我试图运行的命令如下:
java -jar swagger-codegen-cli.jar generate -i swagger.json -l java -c java-config.json -o api-client
Run Code Online (Sandbox Code Playgroud) 任何人都可以解释为什么以下不编译?
byte b = 255 << 1
Run Code Online (Sandbox Code Playgroud)
错误:
常量值'510'无法转换为'字节'
我期待二进制中的以下内容:
1111 1110
Run Code Online (Sandbox Code Playgroud)
类型转换困扰了我.
swagger ×5
c# ×2
openapi ×2
swagger-2.0 ×2
swagger-ui ×2
.net ×1
bit-shift ×1
coding-style ×1
indentation ×1
installer ×1
nunit ×1
pretty-print ×1
python ×1
spring-boot ×1
springfox ×1
sql ×1