Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/int128/swagger-vendor-extensions
Example using Vendor Extensions in Swagger Template
https://github.com/int128/swagger-vendor-extensions
code-generation openapi swagger
Last synced: 27 days ago
JSON representation
Example using Vendor Extensions in Swagger Template
- Host: GitHub
- URL: https://github.com/int128/swagger-vendor-extensions
- Owner: int128
- Created: 2017-08-13T16:05:37.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-07-04T12:06:56.000Z (over 4 years ago)
- Last Synced: 2024-10-27T07:50:27.216Z (3 months ago)
- Topics: code-generation, openapi, swagger
- Language: HTML
- Homepage:
- Size: 67.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Swagger vendor extensions in Mustache template
This repository explains how to access vendor extensions in a Mustache template on Swagger Codegen.
## How to implement Mustache
Add vendor extensions in the OpenAPI YAML.
```yaml
definitions:
Pet:
properties:
code:
type: string
# vendor extension begins with x-
x-validations:
isbn13: true
```Vendor extensions can be accessed in a template by the `vendorExtensions` property.
```mustache
{{#vendorExtensions.x-validations.isbn13}}
// Access vendor extensions in Mustache template
@ISBN13
{{/vendorExtensions.x-validations.isbn13}}
```## Example
This repository contains an example of using vendor extensions.
Generate code.
```bash
./gradlew generateSwaggerCode
```Then open `build/swagger-code/src/main/java/example/model/Pet.java`.
```java
public class Pet {
private Long id = null;
private String name = null;@ISBN13
private String code = null;// snip...
```