# Openapi Swagger > This directory contains comprehensive documentation for OpenAPI specification and Swagger tools, extracted from official sources. --- # OpenAPI/Swagger Documentation Summary ## What's Included This directory contains comprehensive documentation for OpenAPI specification and Swagger tools, extracted from official sources. ## Source Materials ### 1. OpenAPI Specification (OAI/OpenAPI-Specification GitHub) - **versions-3.1.0.md** (3,470 lines, 128KB) - Current latest OpenAPI specification - Complete schema definitions and examples - All object types and properties - **versions-3.0.3.md** (3,456 lines, 123KB) - OpenAPI 3.0.3 specification - Full reference for 3.0.x implementations - **versions-2.0.md** (2,300 lines, 79KB) - Swagger 2.0 specification - Legacy specification for backwards compatibility - **README.md** (56 lines, 5.5KB) - Overview of OpenAPI specification - Project governance and direction - **CONTRIBUTING.md** (544 lines, 29KB) - Contribution guidelines for OpenAPI - Development workflow and process - **SECURITY_CONSIDERATIONS.md** (28 lines, 2.1KB) - Security best practices for API definitions ### 2. Swagger.io Documentation - **docs.md** (27 lines, 2.4KB) - Main documentation hub overview - **docs-specification-basic-structure.md** (45 lines, 4.6KB) - Basic OpenAPI document structure - Key concepts and organization - **docs-specification-describing-parameters.md** (253 lines, 23KB) - Parameter definition and description - Query, path, header, and cookie parameters - Parameter validation and examples - **docs-specification-paths-and-operations.md** (108 lines, 8.6KB) - Defining API endpoints and operations - HTTP methods and operations - Path variables and templating - **docs-specification-authentication.md** (110 lines, 10KB) - Security schemes and authentication - OAuth2, API key, HTTP authentication - Bearer token implementation - **docs-specification-serialization.md** (65 lines, 7.1KB) - Request/response body serialization - Media type handling and encoding ### 3. Swagger Codegen Documentation - **docs-open-source-tools-swagger-codegen-codegen-v3-about.md** (190 lines, 14KB) - Swagger Codegen v3 overview - Code generation capabilities - Supported languages and frameworks - **docs-open-source-tools-swagger-codegen-codegen-v3-generators.md** (46 lines, 3.2KB) - Available code generators - Generator configurations ## Key Topics Covered ### API Specification - Complete OpenAPI 3.1.0 specification reference - OpenAPI 3.0.3 specification - Swagger 2.0 legacy support - Information objects and metadata - Server variables and environments ### API Design - RESTful endpoint design - Parameter validation and description - Request/response modeling - Status codes and error handling - API versioning strategies ### Authentication & Security - OpenAPI security schemes - OAuth 2.0 implementation - API key authentication - HTTP authentication methods - Security considerations and best practices ### Tools & Implementation - Swagger Codegen for client/server generation - Code generation from OpenAPI specs - Multiple language support - Integration with development workflows ### Governance - Contributing to OpenAPI specification - Change management process - Specification versioning - Community involvement ## Usage This documentation is optimized for LLM consumption and provides: 1. Complete specification reference for implementing OpenAPI 2. Practical examples from Swagger.io 3. Tool documentation for code generation 4. Best practices and guidelines ### For API Development - Reference the specification versions for correct OpenAPI syntax - Use Swagger tools documentation for implementation guidance - Review authentication and security sections for secure API design ### For Tool Integration - Swagger Codegen documentation for automated code generation - Examples of specification-driven development - Integration patterns and workflows ## File Statistics - **Total Files**: 15 markdown documents - **Total Content**: 10,743 lines - **Total Size**: 437.8 KB - **Specification Versions**: 3 (2.0, 3.0.3, 3.1.0) - **Documentation Pages**: 8 (from swagger.io) - **Additional Resources**: 4 (README, CONTRIBUTING, SECURITY, INDEX) ## Sources - **OpenAPI Specification**: https://github.com/OAI/OpenAPI-Specification - **Swagger.io**: https://swagger.io/ - **Official Spec**: https://spec.openapis.org/ ## Recommendation For LLM use: 1. Start with versions-3.1.0.md for current OpenAPI reference 2. Review specification-describing-parameters and paths for practical API design 3. Check authentication documentation for security implementation 4. Use codegen documentation for tool integration --- # Source: https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/SECURITY_CONSIDERATIONS.md # Security Considerations ## OpenAPI Document Formats OpenAPI documents use JSON, YAML, and JSON Schema, and therefore share their security considerations: - [JSON](https://www.iana.org/assignments/media-types/application/json) - [YAML](https://www.iana.org/assignments/media-types/application/yaml) - [JSON Schema Core](https://json-schema.org/draft/2020-12/json-schema-core#section-13) - [JSON Schema Validation](https://json-schema.org/draft/2020-12/json-schema-validation#name-security-considerations) ## Tooling and Usage Scenarios In addition, OpenAPI documents are processed by a wide variety of tooling for numerous different purposes, such as client code generation, documentation generation, server side routing, and API testing. OpenAPI document authors must consider the risks of the scenarios where the OpenAPI document may be used. ## Security Schemes An OpenAPI document describes the security schemes used to protect the resources it defines. The security schemes available offer varying degrees of protection. Factors such as the sensitivity of the data and the potential impact of a security breach should guide the selection of security schemes for the API resources. Some security schemes, such as basic auth and OAuth Implicit flow, are supported for compatibility with existing APIs. However, their inclusion in OpenAPI does not constitute an endorsement of their use, particularly for highly sensitive data or operations. ## Handling External Resources OpenAPI documents may contain references to external resources that may be dereferenced automatically by consuming tools. External resources may be hosted on different domains that may be untrusted. References in an OpenAPI document, or across OpenAPI documents may cause a cycle. Tooling must detect and handle cycles to prevent resource exhaustion. ## Markdown and HTML Sanitization Certain properties allow the use of Markdown which can contain HTML including script. It is the responsibility of tooling to appropriately sanitize the Markdown. --- # Source: https://swagger.io/docs/open-source-tools/swagger-codegen/codegen-v3/about # Swagger Codegen This is the Swagger Codegen project, which allows generation of API client libraries (SDK generation), server stubs and documentation automatically given anOpenAPI Description. [OpenAPI Description](https://github.com/OAI/OpenAPI-Specification) 💚 If you would like to contribute, please refer toguidelinesand a list ofopen tasks.💚 [guidelines](https://github.com/swagger-api/swagger-codegen/blob/master/CONTRIBUTING.md) [open tasks](https://github.com/swagger-api/swagger-codegen/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) 📔 For more information, please refer to theWiki pageandFAQ📔 [Wiki page](https://github.com/swagger-api/swagger-codegen/wiki) [FAQ](https://github.com/swagger-api/swagger-codegen/wiki/FAQ) ⚠️ If the OpenAPI Description or Swagger file is obtained from an untrusted source, please make sure you’ve reviewed the artefact before using Swagger Codegen to generate the API client, server stub or documentation ascode injectionmay occur. ⚠️ [code injection](https://en.wikipedia.org/wiki/Code_injection) ## Versioning ⚠️ this document refers to version 3.X, checkherefor 2.X. [here](./../codegen-v2/about) Both 2.X and 3.X version lines of Swagger Codegen are available and are independently maintained. NOTES: - Versions 2.X (io.swagger) and 3.X (io.swagger.codegen.v3) havedifferentgroup ids. `io.swagger` `io.swagger.codegen.v3` - OpenAPI 3.0.X is supported from the 3.X version only For full versioning info, please refer to theversioning documentation. [versioning documentation](../versioning) ## Supported Languages and Frameworks Here’s a summary of the supported languages/frameworks. - API clients: “csharp”, “csharp-dotnet2”, “dart”, “go”, “java”, “javascript”, “jaxrs-cxf-client”, “kotlin-client”, “php”, “python”, “r”, “ruby” “scala”, “swift3”, “swift4”, “swift5”, “typescript-angular”, “typescript-axios”, “typescript-fetch” API clients: “csharp”, “csharp-dotnet2”, “dart”, “go”, “java”, “javascript”, “jaxrs-cxf-client”, “kotlin-client”, “php”, “python”, “r”, “ruby” “scala”, “swift3”, “swift4”, “swift5”, “typescript-angular”, “typescript-axios”, “typescript-fetch” - Server stubs: “aspnetcore”, “go-server”, “inflector”, “java-vertx”, “jaxrs-cxf”, “jaxrs-cxf-cdi”, “jaxrs-di”, “jaxrs-jersey”, “jaxrs-resteasy”, “jaxrs-resteasy-eap”, “jaxrs-spec”, “kotlin-server”, “micronaut”, “nodejs-server”, “python-flask”, “scala-akka-http-server”, “spring” Server stubs: “aspnetcore”, “go-server”, “inflector”, “java-vertx”, “jaxrs-cxf”, “jaxrs-cxf-cdi”, “jaxrs-di”, “jaxrs-jersey”, “jaxrs-resteasy”, “jaxrs-resteasy-eap”, “jaxrs-spec”, “kotlin-server”, “micronaut”, “nodejs-server”, “python-flask”, “scala-akka-http-server”, “spring” - API documentation generators: “dynamic-html”, “html”, “html2”, “openapi”, “openapi-yaml” API documentation generators: “dynamic-html”, “html”, “html2”, “openapi”, “openapi-yaml” To get a complete and/or realtime listing of supported languages/frameworks, you can directly query theonline generator APIor via acURLcommand. [online generator API](https://generator3.swagger.io/index.html#/clients/languages) `cURL` ``` 1curl -X 'GET' \2 'https://generator3.swagger.io/api/client/V3' \3 -H 'accept: application/json'``` `1curl -X 'GET' \2'https://generator3.swagger.io/api/client/V3' \3-H 'accept: application/json'` Check out theOpenAPI Specificationfor additional information about the OpenAPI project. [OpenAPI Specification](https://github.com/OAI/OpenAPI-Specification) ## Compatibility The OpenAPI Specification has undergone 3 revisions since initial creation in 2010. Thecurrent stableversions of Swagger Codegen project have the following compatibilities with the OpenAPI Specification: [3.0.71](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.71) [tag v3.0.71](https://github.com/swagger-api/swagger-codegen/tree/v3.0.71) [2.4.46](https://github.com/swagger-api/swagger-codegen/releases/tag/v2.4.46) [tag v2.4.46](https://github.com/swagger-api/swagger-codegen/tree/v2.4.46) 💁 Here’s also an overview of what’s coming around the corner: [SNAPSHOT](https://central.sonatype.com/service/rest/repository/browse/maven-snapshots/io/swagger/codegen/v3/swagger-codegen-cli/3.0.72-SNAPSHOT/) [SNAPSHOT](https://central.sonatype.com/service/rest/repository/browse/maven-snapshots/io/swagger/swagger-codegen-cli/2.4.47-SNAPSHOT/) For detailed breakdown of all versions, please see thefull compatibility listing. [full compatibility listing](../compatibility) ## Getting Started To get up and running with Swagger Codegen, check out the following guides and instructions: - Prerequisites [Prerequisites](../prerequisites) - Building [Building](../building) - Using Docker [Using Docker](../docker) Once you’ve your environment setup, you’re ready to start generating clients and/or servers. As a quick example, to generate a PHP client forSwagger Petstore, please run the following: [Swagger Petstore](http://petstore.swagger.io/v2/swagger.json) ``` 1git clone https://github.com/swagger-api/swagger-codegen2cd swagger-codegen3git checkout 3.0.04mvn clean package5java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \6 -i http://petstore.swagger.io/v2/swagger.json \7 -l php \8 -o /var/tmp/php_api_client``` Note:if you’re on Windows, replace the last command with: ``` 1java -jar modules\swagger-codegen-cli\target\swagger-codegen-cli.jar generate -i http://petstore.swagger.io/v2/swagger.json -l php -o c:\temp\php_api_client``` You can also download the JAR (latest release) directly frommaven.org. [maven.org](https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.71/swagger-codegen-cli-3.0.71.jar) To get a list ofgeneraloptions available, please run: ``` 1java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate --help``` `1java-jarmodules/swagger-codegen-cli/target/swagger-codegen-cli.jargenerate--help` To get a list of PHP specified options (which can be passed to the generator with a config file via the-coption), please run: `-c` ``` 1java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar config-help -l php``` `1java-jarmodules/swagger-codegen-cli/target/swagger-codegen-cli.jarconfig-help-lphp` ## Generators ### To generate a sample client library You can build a client against the swagger samplepetstoreAPI as follows: [petstore](http://petstore.swagger.io) ``` 1./bin/java-petstore.sh``` `1./bin/java-petstore.sh` On Windows, run.\bin\windows\java-petstore.batinstead. `.\bin\windows\java-petstore.bat` This will run the generator with this command: ``` 1java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \2 -i http://petstore.swagger.io/v2/swagger.json \ # The location of the Swagger specifcation file (JSON/YAML).3 -l java \ # The desired language for the library.4 -o samples/client/petstore/java # The output destination.``` You can get the options with thegenerate --helpcommand (below only shows partial results): `generate --help` ``` 1NAME2 swagger-codegen-cli generate - Generate code with chosen lang3 4SYNOPSIS5 swagger-codegen-cli generate6 [(-a | --auth )]7 [--additional-properties ...]8 [--api-package ] [--artifact-id ]9 [--artifact-version ]10 [(-c | --config )]11 [-D ...] [--git-repo-id ]12 [--git-user-id ] [--group-id ]13 [--http-user-agent ]14 (-i | --input-spec )15 [--ignore-file-override ]16 [--import-mappings ...]17 [--instantiation-types ...]18 [--invoker-package ]19 (-l | --lang )20 [--language-specific-primitives ...]21 [--library ] [--model-name-prefix ]22 [--model-name-suffix ]23 [--model-package ]24 [(-o | --output )]25 [--release-note ] [--remove-operation-id-prefix]26 [--reserved-words-mappings ...]27 [(-s | --skip-overwrite)]28 [(-t