# swagger-parser **Repository Path**: mirrors_OpenAPITools/swagger-parser ## Basic Information - **Project Name**: swagger-parser - **Description**: Fork of swagger-api/swagger-parser - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: 2.0-OpenAPITools - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-25 - **Last Updated**: 2026-01-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # IMPORTANT [![Build Status](https://travis-ci.org/OpenAPITools/swagger-parser.svg?branch=2.0-OpenAPITools)](https://travis-ci.org/OpenAPITools/swagger-parser) This is a fork of [swagger-api/swagger-parser](https://github.com/swagger-api/swagger-parser) to work on use cases for [OpenAPI Generator](https://github.com/OpenAPITools/openapi-generator). Work is made in the `2.0-OpenAPITools` branch, which is aligned with the `master` branch of the original project. Maven `groupId` was changed to: `org.openapitools.swagger.parser` There are `SNAPSHOT` and [released](https://github.com/OpenAPITools/swagger-parser/releases) versions from this branch. Released versions use `OpenAPITools.org-*` suffix in their name to distinguish them from official version. Last released version: ```xml org.openapitools.swagger.parser swagger-parser 2.0.14-OpenAPITools.org-1 ``` Released versions should be used until the next official compatible version is published. If you want to change something in this project, be sure to also file a PR in [swagger-api/swagger-parser](https://github.com/swagger-api/swagger-parser/pulls). :bangbang: Both "OpenAPI Tools" (https://OpenAPITools.org - the parent organization of this project) and "OpenAPI Generator" are not affiliated with OpenAPI Initiative (OAI) --- # Swagger Parser ## Overview This is the Swagger Parser project, which reads OpenAPI definitions into current Java POJOs. It also provides a simple framework to add additional converters from different formats into the Swagger objects, making the entire toolchain available. ### Usage Using the Swagger Parser is simple. Once included in your project, you can read a OpenAPI Specification from any location: ```java import io.swagger.v3.parser.OpenAPIV3Parser; import io.swagger.v3.oas.models.OpenAPI; // ... your code // read a swagger description from the petstore OpenAPI openAPI = new OpenAPIV3Parser().read("http://petstore.swagger.io/v3/openapi.json"); ``` You can read from a file location as well: ```java OpenAPI openAPI = new OpenAPIV3Parser().read("./path/to/openapi.yaml"); ``` If your OpenAPI definition is protected, you can pass headers in the request: ```java import io.swagger.v3.parser.core.models.AuthorizationValue; // ... your code // build a authorization value AuthorizationValue mySpecialHeader = new AuthorizationValue() .keyName("x-special-access") // the name of the authorization to pass .value("i-am-special") // the value of the authorization .type("header"); // the location, as either `header` or `query` // or in a single constructor AuthorizationValue apiKey = new AuthorizationValue("api_key", "special-key", "header"); OpenAPI openAPI = new OpenAPIV3Parser().readWithInfo( "http://petstore.swagger.io/v2/swagger.json", Arrays.asList(mySpecialHeader, apiKey) ); ``` ### Dealing with self-signed SSL certificates If you're dealing with self-signed SSL certificates, or those signed by GoDaddy, you'll need to disable SSL Trust Manager. That's done by setting a system environment variable as such: ``` export TRUST_ALL=true ``` And then the Swagger Parser will _ignore_ invalid certificates. Of course this is generally a bad idea, but if you're working inside a firewall or really know what you're doing, well, there's your rope. ### Dealing with Let's Encrypt Depending on the version of Java that you use, certificates signed by the [Let's Encrypt](https://letsencrypt.org) certificate authority _may not work_ by default. If you are using any version of Java prior to 1.8u101, you most likely _must_ install an additional CA in your JVM. Also note that 1.8u101 may _not_ be sufficient on it's own. Some users have reported that certain operating systems are not accepting Let's Encrypt signed certificates. Your options include: * Accepting all certificates per above * Installing the certificate manually in your JVM using the keystore using the `keytool` command * Configuring the JVM on startup to load your certificate But... this is all standard SSL configuration stuff and is well documented across the web. ### Prerequisites You need the following installed and available in your $PATH: * [Java 1.8](http://java.oracle.com) * [Apache maven 3.x](http://maven.apache.org/) After cloning the project, you can build it from source with this command: ``` mvn package ``` ### Extensions This project has a core artifact--`swagger-parser`, which uses Java Service Provider Inteface (SPI) so additional extensions can be added. To build your own extension, you simply need to create a `src/main/resources/META-INF/services/io.swagger.parser.SwaggerParserExtension` file with the full classname of your implementation. Your class must also implement the `io.swagger.parser.SwaggerParserExtension` interface. Then, including your library with the `swagger-parser` module will cause it to be triggered automatically. ### Adding to your project You can include this library from Sonatype OSS for SNAPSHOTS, or Maven central for releases. In your dependencies: ```xml io.swagger.parser.v3 swagger-parser 2.0.14 ``` ## Security contact Please disclose any security-related issues or vulnerabilities by emailing [security@swagger.io](mailto:security@swagger.io), instead of using the public issue tracker. License ------- Copyright 2018 SmartBear Software Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0) Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ---