swagger2
Swagger 2.0 data model
https://github.com/GetShopTV/swagger2
| Version on this page: | 2.8.9 | 
| LTS Haskell 24.17: | 2.8.10 | 
| Stackage Nightly 2025-07-18: | 2.8.10 | 
| Latest on Hackage: | 2.8.10 | 
swagger2-2.8.9@sha256:8434f71bf8017c1421d85ee8021e3f56f45f15c8ba50fff55f7329ace4cb0076,4518swagger2
Swagger 2.0 data model.
The original Swagger 2.0 specification is available at http://swagger.io/specification/.
Usage
This library is intended to be used for decoding and encoding Swagger 2.0 API specifications as well as manipulating them.
Please refer to haddock documentation.
Some examples can be found in examples/ directory.
Trying out
All generated swagger specifications can be interactively viewed on Swagger Editor.
Ready-to-use specification can be served as JSON and interactive API documentation can be displayed using Swagger UI.
Many Swagger tools, including server and client code generation for many languages, can be found on Swagger’s Tools and Integrations page.
Contributing
We are happy to receive bug reports, fixes, documentation enhancements, and other improvements.
Please report bugs via the github issue tracker.
GetShopTV Team
Changes
2.8.9
- Support GHC 9.10 (see #255)
2.8.8
- Support GHC 9.8 (see #249);
2.8.7
2.8.6
- Support GHC 9.4 (see #244);
2.8.5
- Add newer dependencies (i.e. aeson,lens, etc.) (see #242);
2.8.4
- Add GHC 9.2.3to CI Matrix and bump stack resolver tolts-19.11(see #237);
2.8.3
2.8.2
- text-2.0support (see #234);
2.8.1
- Better error message in validateSchemaType(see #221);
2.8
2.7
- Upgrade aesonto2.0.1.0(see #228);
- Switch from Travis CI to GitHub Actions (see #228);
- GHC 9 support (see #228);
- More GHC-8.10 related cleanup, tighten lower bound on some dependencies. (see #216);
- Add “format” field for uint32 and uint64 (see #215);
2.6
- GHC 8.10 support (see #210);
- Move aeson-prettyto other dependencies (see #206);
- Merge OAuth2 scopes (see #151);
2.5
Highlights:
- Add instance for TimeOfDay(see #196);
- Add support for optics(see #200);
- Slightly better validation errors (see #195);
Fixes and minor changes:
- Minor cleanup (see #194);
- Allow base-4.13 and other GHC-8.8 related stuff (see #198);
- Fix stack.yaml(see #201);
2.4
- Allow hashable-1.3, semigroups-0.19, network-3.1, time-1.9, generics-sop-0.5
- Tags aren’t sorted (see #165)
- Schema type is optional (see #138, #164)
- Take concrete ‘Proxy’ as argument (see #180)
- GHC-8.8 preparations
2.3.1.1
- Allow network-3.0
2.3.1
- Add a quickcheck generator for aeson Values that match a swagger schema (see #162)
- Add ToParamSchemainstance forSetCookie(see #173)
- Make nullary schemas valid (see #168)
2.3.0.1
- Support GHC-8.6
2.3
Major changes:
- Add support for additionalPropertieswithBoolvalue (see #159);
- Add ToSchemaObjectinstance (for aeson’sObject) (seed72466a);
Dependencies and CI:
- Aeson 1.4 (see #158);
- Update .travis.yml (see #160);
- Allow network 2.7 (see #155);
- Allow lens-4.17 (see #161);
2.2.2
- Add ToSchema Versioninstance
- Use base-compat-batteries (0.10)
- PVP bounds
2.2.1
- Add Semigroupinstances
- GHC-8.4 compatibility
- `Schema (NonEmpty a) instance (see #141)
- Fix optional property for unary records (see #142)
- Add fromAesonOptionshelper (see #146)
- Fix non-termination when using datatypeNameModifierwith recursive data types (see #132)
2.2
- Treat unknown properties as validation errors in validateToJSON(see #126);
- Add validateJSONandvalidateJSONWithPatternCheckerto validate JSONValueagainstSchemawithout classes (see #126);
- Add more Schemahelpers (see #126):- genericNameSchema— to give a custom schema- Generic-based name;
- genericDeclareNamedSchemaNewtype— to derive- NamedSchemafor- newtypes;
- declareSchemaBoundedEnumKeyMapping— to derive more specific- Schemafor maps with- Bounded- Enumkeys;
 
- Add a few tests with invalid Schema.
2.1.6
- Add ToParamSchemaandToSchemainstances forFixed(see #121) andNatural(see #123);
- Fix instance for NominalDiffTime(see #121);
- Fix build for aeson-1.2.2.0(see #125).
2.1.5
- Type error by default when deriving Generic-based instances for mixed sum types (see #118);
- Adjust allOfto accept referenced schemas (see #119);
- Add instances for Identity(see #116);
- Add Gitter chat badge (see #114).
2.1.4.1
- GHC-8.2 support (see #95, #106 and #108);
- Documentation corrections (see #105);
- Allow generics-sop-0.3(see #102);
- Fix ToSchemaexample in docs (see #104).
2.1.4
2.1.3
- Add UUIDinstances (see #81).
- Add TypeErrorToSchemaandToParamSchema ByteStringinstances (see #78)
- Improve documentation for generic sum type instance derivation (see #75)
- Compile warning free (see #82)
2.1.2.1
- Bug fix previous release
2.1.2
- Minor changes:
- Support aeson-1.0.0.0(see #70).
 
- Support 
2.1.1
- Minor changes:
- Proper Schemaexamples forChar,Day,LocalTime,ZonedTimeandUTCTime.
 
- Proper 
2.1
- Major changes:
2.0.2
- Fixes:
- Fix additionalPropertiesto allow references;
- Fix ToSchemainstances forMapandHashMap(prevent infinite recursion for recursive values).
 
- Fix 
2.0.1
- Fixes:
- Re-export Patternsynonym fromData.Swagger;
- Documentation fixes.
 
- Re-export 
2.0
- 
Major changes: 
- 
Minor changes: 
- 
Fixes: - Fix schema for ()and nullary constructors (see ab65c4a);
- Fix OperationFromJSONinstance to allow missingtagsandparametersproperties.
 
- Fix schema for 
1.2.1
- 
Minor changes: - Change _SwaggerItemsPrimitivetype from aPrism'to a more restrictiveReview-likeOptic'.
 
- Change 
- 
Fixes: - Fix build for GHC 8.0-rc1.
 
1.2
- 
Minor changes (see #36): - Change default ToSchemainstance for unit data types (i.e. types with one nullable constructor likedata Unit = Unit): now these types are treated like sum types with only one alternative;
- Add generic ToParamSchemainstance for unit data types;
- Add items: []to schema for()(making it a valid schema).
 
- Change default 
- 
Fixes: - Do not omit items: []fromSchemaJSON;
- Do not generate unused definitions for nested newtypes (see #38).
 
- Do not omit 
1.1.1
- Fixes:
- CollectionFormat Param->- CollectionFormat ParamOtherSchema; this change was necessary after putting- CollectionFormatto- SwaggerItems.
 
1.1
- 
Major changes: - Put CollectionFormatin one place (see3cc860d).
 
- Put 
- 
Minor changes: - Use Swagger formats for Int32,Int64,Float,Double,DayandZonedTime(see #32);
- Export HeaderName,TagName,HttpStatusCodetype synonyms;
- Add ToParamSchemainstances for[a],Set aandHashSet a;
- Add Monoidinstances forHeaderandExample.
 
- Use Swagger formats for 
- 
Fixes: - Use overwrite strategy for HashMapSwaggerMonoidinstances by default.
 
- Use overwrite strategy for 
1.0
- 
Major changes: - Add DataandTypeableinstances forData.Swaggertypes;
- Merge ParamType/ItemsType/SchemaTypeintoSwaggerTypeGADT;
- Merge collection format types into CollectionFormatGADT;
- Introduce SwaggerItemsGADT, replacingItemsandSchemaItemsinParamSchema(see #24);
- Move type, format and items fields to ParamSchema(formerSchemaComon);
- Prepend reference path automatically (see commit 49d1fad)
and thus remove "#/definitions/"from user code, leaving much clearerReference "Name";
- Change Data.Swagger.Schema(see #19):- Change the only method of ToSchematodeclareNamedSchemawhich should produce aNamedSchemaalong with a list of schema definitions used to produce it;
- Add declareSchema,declareSchemaRef;
- Replace genericTo*helpers withgenericDeclare*helpers;
- Add paramSchemaTo[Named]Schemahelpers to facilitate code reuse for primitive schemas;
- Add helpers for inlining Schemareferences dynamically (see #23);
 
- Change the only method of 
- Add ToParamSchemaclass (see #17) with- generic default implementation and
- instances for some base types compliant with http-api-datainstances;
 
- Add Data.Swagger.Declaremodule with- DeclareTmonad transformer;
- MonadDeclaretype class;
- various helpers;
 
- Rename parameter-related types:
- Parameter->- Param;
- ParameterSchema->- ParamAnySchema;
- ParameterOtherSchema->- ParamOtherSchema;
- ParameterLocation->- ParamLocation;
- SchemaCommon->- ParamSchema;
- parameter*fields renamed to- param*fields;
- schemaCommon*fields renamed to- paramSchema*fields;
- HasSchemaCommon->- HasParamSchema.
 
 
- Add 
- 
Minor changes: - Replace TH-generated JSON instances with Generic-based (see #25);
- Drop template-haskelldependency;
- Omit empty array/object properties from toJSONoutput (#22);
- Remove minLengthproperty from schemas fortimetypes;
- Move SchemaOptionstoData.Swagger.SchemaOptions;
- Remove useReferencesfromSchemaOptions(see #23);
- Place all internal submodules under Data.Swagger.Internal;
- Better documentation (see #26).
 
- Replace TH-generated JSON instances with 
0.4.1
- Fixes:
- Use PackageImportsforData.HashSetto avoid test failure on stackage (see #15);
- Add an upper version bound for aesondue toaeson-0.10.0.0bug (see bos/aeson#293);
- Switch to Cabal-based multi GHC Travis config.
 
- Use 
0.4
- Remove Swagger/swaggerprefixes;
- Add ToSchematype class with default generic implementation;
- Add configurable generic ToSchemahelpers;
- Add doctesttest suite;
- Fixes:
- Fix HasSchemaCommoninstance forSchema;
- Change minimum,maximumandmultipleOfproperties to be any number, not necessarily an integer;
- Fix all warnings.
 
- Fix 
0.3
- Fixes:
- Fix SwaggerMonoid Textinstance;
- Wrap BoolinMaybeeverywhere;
- These changes make all Data.SwaggerMonoidinstances obey monoid laws (previously right identity law was broken by some instances).
 
- Fix 
0.2
- Add Data.Swagger.Lens;
- Support references;
- Fixes:
- Fix FromJSON SwaggerHostinstance;
- Add missing Maybes for field types;
- Decode petstore swagger.jsonsuccessfully.
 
- Fix 
